diff --git a/main.cpp b/main.cpp index f80c950..f4ea93d 100644 --- a/main.cpp +++ b/main.cpp @@ -38,6 +38,8 @@ public: // TODO: If Swap is implemented with std::swap instead of deleting the current object, this should not be done! // However, that would mean that the old object can stay in memory unnecessarily long (until 'other' goes out of scope) other.object = nullptr; + + return *this; } /// Destructor @@ -136,7 +138,7 @@ void customTestObjectDeleter(TestObject *object) { int main() { { std::cout << "Constructing first pointer" << std::endl; - UniquePtr pointer = UniquePtr(new TestObject()); + UniquePtr pointer = UniquePtr(new TestObject()); std::cout << "Calling test print via pointer if it bools to true" << std::endl; if (pointer) { @@ -147,10 +149,10 @@ int main() { pointer.Swap(new TestObject()); std::cout << "Move assigning new pointer" << std::endl; - UniquePtr pointer2 = UniquePtr(std::move(pointer)); + UniquePtr pointer2 = UniquePtr(std::move(pointer)); std::cout << "Constructing pointer with custom deleter" << std::endl; - UniquePtr pointer3 = UniquePtr(new TestObject(), customTestObjectDeleter); + UniquePtr pointer3 = UniquePtr(new TestObject(), customTestObjectDeleter); std::cout << "Resetting that pointer" << std::endl; pointer3.Reset(); @@ -160,8 +162,8 @@ int main() { } std::cout << "Moving into a pointer which already has an object" << std::endl; - UniquePtr pointer4 = UniquePtr(new TestObject()); - UniquePtr pointer5 = UniquePtr(new TestObject()); + UniquePtr pointer4 = UniquePtr(new TestObject()); + UniquePtr pointer5 = UniquePtr(new TestObject()); pointer4 = std::move(pointer5); }