![]() |
XII Release 0.1.0
|
A Unique ptr manages an object and destroys that object when it goes out of scope. It is ensure that only one unique ptr can manage the same object. More...
#include <UniquePtr.h>
Public Member Functions | |
XII_DECLARE_MEM_RELOCATABLE_TYPE () | |
xiiUniquePtr () | |
Creates an empty unique ptr. | |
template<typename U> | |
xiiUniquePtr (const xiiInternal::NewInstance< U > &instance) | |
Creates a unique ptr from a freshly created instance through XII_NEW or XII_DEFAULT_NEW. | |
template<typename U> | |
xiiUniquePtr (U *pInstance, xiiAllocatorBase *pAllocator) | |
Creates a unique ptr from a pointer and an allocator. The passed allocator will be used to destroy the instance when the unique ptr goes out of scope. | |
template<typename U> | |
xiiUniquePtr (xiiUniquePtr< U > &&other) | |
Move constructs a unique ptr from another. The other unique ptr will be empty afterwards to guarantee that there is only one unique ptr managing the same object. | |
xiiUniquePtr (std::nullptr_t) | |
Initialization with nullptr to be able to return nullptr in functions that return unique ptr. | |
~xiiUniquePtr () | |
Destroys the managed object using the stored allocator. | |
template<typename U> | |
xiiUniquePtr< T > & | operator= (const xiiInternal::NewInstance< U > &instance) |
Sets the unique ptr from a freshly created instance through XII_NEW or XII_DEFAULT_NEW. | |
template<typename U> | |
xiiUniquePtr< T > & | operator= (xiiUniquePtr< U > &&other) |
Move assigns a unique ptr from another. The other unique ptr will be empty afterwards to guarantee that there is only one unique ptr managing the same object. | |
xiiUniquePtr< T > & | operator= (std::nullptr_t) |
Same as calling 'Reset()'. | |
T * | Release () |
Releases the managed object without destroying it. The unique ptr will be empty afterwards. | |
T * | Release (xiiAllocatorBase *&out_pAllocator) |
Releases the managed object without destroying it. The unique ptr will be empty afterwards. Also returns the allocator that should be used to destroy the object. | |
T * | Borrow () const |
Borrows the managed object. The unique ptr stays unmodified. | |
void | Clear () |
Destroys the managed object and resets the unique ptr. | |
T & | operator* () const |
Provides access to the managed object. | |
T * | operator-> () const |
Provides access to the managed object. | |
operator bool () const | |
Returns true if there is managed object and false if the unique ptr is empty. | |
bool | operator== (const xiiUniquePtr< T > &rhs) const |
Compares the unique ptr against another unique ptr. | |
std::strong_ordering | operator<=> (const xiiUniquePtr< T > &rhs) const |
Compares the unique ptr against another unique ptr. | |
bool | operator== (std::nullptr_t) const |
Compares the unique ptr against nullptr. | |
std::strong_ordering | operator<=> (const std::nullptr_t) const |
Compares the unique ptr against nullptr. | |
template<typename U> | |
XII_ALWAYS_INLINE | xiiUniquePtr (const xiiInternal::NewInstance< U > &instance) |
template<typename U> | |
XII_ALWAYS_INLINE | xiiUniquePtr (U *pInstance, xiiAllocatorBase *pAllocator) |
template<typename U> | |
XII_ALWAYS_INLINE | xiiUniquePtr (xiiUniquePtr< U > &&other) |
template<typename U> | |
XII_ALWAYS_INLINE xiiUniquePtr< T > & | operator= (const xiiInternal::NewInstance< U > &instance) |
template<typename U> | |
XII_ALWAYS_INLINE xiiUniquePtr< T > & | operator= (xiiUniquePtr< U > &&other) |
A Unique ptr manages an object and destroys that object when it goes out of scope. It is ensure that only one unique ptr can manage the same object.