Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
UniquePtr< T > Class Template Reference

#include <elm/util/UniquePtr.h>

Public Member Functions

 UniquePtr (void)
 
 UniquePtr (T *ptr)
 
 UniquePtr (UniquePtr< T > &ptr)
 
 ~UniquePtr (void)
 
bool isNull (void) const
 
void clean (void)
 
T * detach (void)
 
void set (T *ptr)
 
T * get (void) const
 
UniquePtr< T > & operator= (T *ptr)
 
UniquePtr< T > & operator= (UniquePtr< T > &ptr)
 
 operator T* (void) const
 
T * operator-> (void) const
 
 operator bool (void) const
 
T & operator* (void) const
 

Detailed Description

template<class T>
class elm::UniquePtr< T >

Implements a pointer wrapper class ensuring there is only one owner of a pointed object. When a unique pointer is deleted, the pointed object is also deleted while when a unique pointer is assigned to another one, it looses the pointed object that is passed to assigned unique pointer.

Parameters
TType of pointed objects.

Constructor & Destructor Documentation

◆ UniquePtr() [1/3]

UniquePtr ( void  )
inline

◆ UniquePtr() [2/3]

UniquePtr ( T *  ptr)
inline

◆ UniquePtr() [3/3]

UniquePtr ( UniquePtr< T > &  ptr)
inline

◆ ~UniquePtr()

~UniquePtr ( void  )
inline

Member Function Documentation

◆ clean()

void clean ( void  )
inline

◆ detach()

T * detach ( void  )
inline

Return the pointer and set it in the object to null (it will no more be automatically fried).

Returns
Stored pointer.

◆ get()

◆ isNull()

bool isNull ( void  ) const
inline

Test if the pointer is null.

Returns
True if the pointer is null, false else.

Referenced by UniquePtr< elm::rtti::PointerType >::operator bool().

◆ operator bool()

operator bool ( void  ) const
inline

Same as !isNull().

◆ operator T*()

operator T* ( void  ) const
inline

Same as get().

References UniquePtr< T >::get().

◆ operator*()

T& operator* ( void  ) const
inline

◆ operator->()

T * operator-> ( void  ) const
inline

Indirect access to the members of stored pointer.

Returns
Stored pointer.

◆ operator=() [1/2]

UniquePtr & operator= ( T *  ptr)
inline

Change the pointer contained in the unique pointer, the old pointer begin fried. Same as set().

Parameters
ptrPointer to set.
Returns
Set unique pointer.

◆ operator=() [2/2]

UniquePtr<T>& operator= ( UniquePtr< T > &  ptr)
inline

◆ set()

void set ( T *  ptr)
inline

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