Changes for other compilers

This commit is contained in:
karl 2019-11-30 21:38:09 +01:00
parent 3a25d4bf26
commit fedfa861b6

View File

@ -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<TestObject>(new TestObject());
UniquePtr<TestObject> pointer = UniquePtr<TestObject>(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<TestObject>(std::move(pointer));
UniquePtr<TestObject> pointer2 = UniquePtr<TestObject>(std::move(pointer));
std::cout << "Constructing pointer with custom deleter" << std::endl;
UniquePtr pointer3 = UniquePtr<TestObject>(new TestObject(), customTestObjectDeleter);
UniquePtr<TestObject> pointer3 = UniquePtr<TestObject>(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<TestObject> pointer4 = UniquePtr<TestObject>(new TestObject());
UniquePtr<TestObject> pointer5 = UniquePtr<TestObject>(new TestObject());
pointer4 = std::move(pointer5);
}