ezEngine  Milestone 7
ezUniquePtr< T > Class Template Reference

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

 EZ_DECLARE_MEM_RELOCATABLE_TYPE ()
 
 ezUniquePtr ()
 Creates an empty unique ptr.
 
template<typename U >
 ezUniquePtr (const ezInternal::NewInstance< U > &instance)
 Creates a unique ptr from a freshly created instance through EZ_NEW or EZ_DEFAULT_NEW.
 
template<typename U >
 ezUniquePtr (U *pInstance, ezAllocatorBase *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 >
 ezUniquePtr (ezUniquePtr< 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.
 
 ~ezUniquePtr ()
 Destroys the managed object using the stored allocator.
 
template<typename U >
void operator= (const ezInternal::NewInstance< U > &instance)
 Sets the unique ptr from a freshly created instance through EZ_NEW or EZ_DEFAULT_NEW.
 
template<typename U >
void operator= (ezUniquePtr< 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.
 
T * Release ()
 Releases the managed object. The unique ptr will be empty afterwards.
 
T * Borrow () const
 Borrows the managed object. The unique ptr stays unmodified.
 
void Reset ()
 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 ezUniquePtr< T > &rhs) const
 Compares the unique ptr against another unique ptr.
 
bool operator!= (const ezUniquePtr< T > &rhs) const
 
bool operator< (const ezUniquePtr< T > &rhs) const
 
bool operator<= (const ezUniquePtr< T > &rhs) const
 
bool operator> (const ezUniquePtr< T > &rhs) const
 
bool operator>= (const ezUniquePtr< 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
 
 EZ_DISALLOW_COPY_AND_ASSIGN (ezUniquePtr)
 
template<typename U >
EZ_FORCE_INLINE ezUniquePtr (const ezInternal::NewInstance< U > &instance)
 
template<typename U >
EZ_FORCE_INLINE ezUniquePtr (U *pInstance, ezAllocatorBase *pAllocator)
 
template<typename U >
EZ_FORCE_INLINE ezUniquePtr (ezUniquePtr< U > &&other)
 
template<typename U >
EZ_FORCE_INLINE void operator= (const ezInternal::NewInstance< U > &instance)
 
template<typename U >
EZ_FORCE_INLINE void operator= (ezUniquePtr< U > &&other)
 

Private Attributes

T * m_pInstance
 
ezAllocatorBasem_pAllocator
 

Friends

template<typename U >
class ezUniquePtr
 

Detailed Description

template<typename T>
class ezUniquePtr< T >

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.


The documentation for this class was generated from the following files: