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

#include <elm/util/SharedPtr.h>

Public Member Functions

 SharedPtr (void)
 
 SharedPtr (T *p)
 
 SharedPtr (const SharedPtr< T > &p)
 
 ~SharedPtr (void)
 
bool isEmpty (void) const
 
T * ptr (void) const
 
T & ref (void) const
 
 operator bool (void) const
 
 operator T* (void) const
 
T * operator-> (void) const
 
T & operator* (void) const
 
T * operator& (void) const
 
SharedPtr< T > & operator= (const SharedPtr< T > &p)
 
SharedPtr< T > & operator= (T *p)
 
bool operator== (const SharedPtr< T > &p) const
 
bool operator!= (const SharedPtr< T > &p) const
 
bool operator== (T *p) const
 
bool operator!= (T *p) const
 

Detailed Description

template<class T>
class elm::SharedPtr< T >

Implements a pointer wrapper class that takes care of the usage of a pointer and that automatically delete a pointed object when it is no more used.

Based on reference counting approach, assignment of shared pointer induces the decrementation of the previous pointer and the incrementation of the new pointer.

Beware: this also means that pointed objects forming a cycle will not be deleted!

Parameters
TType of pointed object.

Constructor & Destructor Documentation

◆ SharedPtr() [1/3]

SharedPtr ( void  )
inline

◆ SharedPtr() [2/3]

SharedPtr ( T *  p)
inline

◆ SharedPtr() [3/3]

SharedPtr ( const SharedPtr< T > &  p)
inline

◆ ~SharedPtr()

~SharedPtr ( void  )
inline

Member Function Documentation

◆ isEmpty()

bool isEmpty ( void  ) const
inline

◆ operator bool()

operator bool ( void  ) const
inline

◆ operator T*()

operator T* ( void  ) const
inline

References SharedPtr< T >::ptr().

◆ operator!=() [1/2]

bool operator!= ( const SharedPtr< T > &  p) const
inline

References elm::io::p().

◆ operator!=() [2/2]

bool operator!= ( T *  p) const
inline

References elm::io::p().

◆ operator&()

T* operator& ( void  ) const
inline

References SharedPtr< T >::ptr().

◆ operator*()

T& operator* ( void  ) const
inline

References SharedPtr< T >::ref().

◆ operator->()

T* operator-> ( void  ) const
inline

References SharedPtr< T >::ptr().

◆ operator=() [1/2]

SharedPtr<T>& operator= ( const SharedPtr< T > &  p)
inline

References elm::io::p().

◆ operator=() [2/2]

SharedPtr<T>& operator= ( T *  p)
inline

References elm::io::p().

◆ operator==() [1/2]

bool operator== ( const SharedPtr< T > &  p) const
inline

References elm::io::p().

◆ operator==() [2/2]

bool operator== ( T *  p) const
inline

References elm::io::p().

◆ ptr()

◆ ref()

T& ref ( void  ) const
inline

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