![]() |
Plasma Engine
2.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 | |
| PL_DECLARE_MEM_RELOCATABLE_TYPE () | |
| plUniquePtr () | |
| Creates an empty unique ptr. | |
| template<typename U > | |
| plUniquePtr (const plInternal::NewInstance< U > &instance) | |
| Creates a unique ptr from a freshly created instance through PL_NEW or PL_DEFAULT_NEW. | |
| template<typename U > | |
| plUniquePtr (U *pInstance, plAllocator *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 > | |
| plUniquePtr (plUniquePtr< 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. | |
| plUniquePtr (std::nullptr_t) | |
| Initialization with nullptr to be able to return nullptr in functions that return unique ptr. | |
| ~plUniquePtr () | |
| Destroys the managed object using the stored allocator. | |
| template<typename U > | |
| plUniquePtr< T > & | operator= (const plInternal::NewInstance< U > &instance) |
| Sets the unique ptr from a freshly created instance through PL_NEW or PL_DEFAULT_NEW. | |
| template<typename U > | |
| plUniquePtr< T > & | operator= (plUniquePtr< 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. | |
| plUniquePtr< 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 (plAllocator *&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 plUniquePtr< T > &rhs) const |
| Compares the unique ptr against another unique ptr. | |
| bool | operator!= (const plUniquePtr< T > &rhs) const |
| bool | operator< (const plUniquePtr< T > &rhs) const |
| bool | operator<= (const plUniquePtr< T > &rhs) const |
| bool | operator> (const plUniquePtr< T > &rhs) const |
| bool | operator>= (const plUniquePtr< T > &rhs) const |
| bool | operator== (std::nullptr_t) const |
| Compares the unique ptr against nullptr. | |
| bool | operator!= (std::nullptr_t) const |
| bool | operator< (std::nullptr_t) const |
| bool | operator<= (std::nullptr_t) const |
| bool | operator> (std::nullptr_t) const |
| bool | operator>= (std::nullptr_t) const |
| template<typename U > | |
| PL_ALWAYS_INLINE | plUniquePtr (const plInternal::NewInstance< U > &instance) |
| template<typename U > | |
| PL_ALWAYS_INLINE | plUniquePtr (U *pInstance, plAllocator *pAllocator) |
| template<typename U > | |
| PL_ALWAYS_INLINE | plUniquePtr (plUniquePtr< U > &&other) |
| template<typename U > | |
| PL_ALWAYS_INLINE plUniquePtr< T > & | operator= (const plInternal::NewInstance< U > &instance) |
| template<typename U > | |
| PL_ALWAYS_INLINE plUniquePtr< T > & | operator= (plUniquePtr< 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.