void Bar() { FooT * foo = new FooT; foo->SomeMethod(); }
void Bar2() { FooT * foo = new FooT; foo->SomeMethod(); delete foo; }
DataT * data{nullptr}; ... UniquePointerT & operator =(UniquePointerT & other) { if (data != nullptr) { delete data; } data = other.data other.data = nullptr; }