#ifndef _UNIQUEPOINTER #define _UNIQUEPOINTER template class UniquePointer { T* value; public: UniquePointer(T* value); UniquePointer(); ~UniquePointer(); UniquePointer(UniquePointer&& other); UniquePointer& operator=(UniquePointer&& other); T& operator*(); const T& operator*() const; T* operator->(); const T* operator->() const; }; template UniquePointer::UniquePointer(T* value) : value(value) { } template UniquePointer::UniquePointer() : value() { } template UniquePointer::~UniquePointer() { delete value; } template UniquePointer::UniquePointer(UniquePointer&& other) { value = other.value; other.value = nullptr; } template UniquePointer& UniquePointer::operator=(UniquePointer&& other) { if (this != &other) { delete value; value = other.value; other.value = nullptr; } return *this; } template T& UniquePointer::operator*() { return *value; } template const T& UniquePointer::operator*() const { return *value; } template T* UniquePointer::operator->() { return value; } template const T* UniquePointer::operator->() const { return value; } #endif /* _UNIQUEPOINTER */