OPTPP::SmartPtr< T > Class Template Reference

#include <OptppSmartPtr.h>

List of all members.

Public Member Functions

 SmartPtr (T *ptr=0)
 SmartPtr (const SmartPtr< T > &other)
 ~SmartPtr ()
const SmartPtr< T > & operator= (const SmartPtr< T > &rhs)
T * operator-> ()
bool isNull () const
const T * operator-> () const
T & operator * ()
const T & operator * () const
 operator const T * () const
bool isNonUnique () const
int refCount () const

Protected Attributes

T * ptr_
int * refCount_


Detailed Description

template<class T>
class OPTPP::SmartPtr< T >

Howard Hinnant's reference counting handle class.

This is to be used as a pointer to class T. This will feel and smell just like a built-in pointer except: 1. There is no need to call delete on the pointer. 2. The default copy constructor and assignment implement ref-counting. 3. The user may call isNonUnique to determine if this pointer is the only pointer to the data. This can be used to hide the ref-counting behavior of a class. 4. Checks for dereference of a null pointer.


Constructor & Destructor Documentation

template<class T>
OPTPP::SmartPtr< T >::SmartPtr ( T *  ptr = 0  )  [inline]

template<class T>
OPTPP::SmartPtr< T >::SmartPtr ( const SmartPtr< T > &  other  )  [inline]

template<class T>
OPTPP::SmartPtr< T >::~SmartPtr (  )  [inline]


Member Function Documentation

template<class T>
bool OPTPP::SmartPtr< T >::isNonUnique (  )  const [inline]

template<class T>
bool OPTPP::SmartPtr< T >::isNull (  )  const [inline]

template<class T>
const T & OPTPP::SmartPtr< T >::operator * (  )  const [inline]

template<class T>
T & OPTPP::SmartPtr< T >::operator * (  )  [inline]

template<class T>
OPTPP::SmartPtr< T >::operator const T * (  )  const [inline]

template<class T>
const T * OPTPP::SmartPtr< T >::operator-> (  )  const [inline]

template<class T>
T * OPTPP::SmartPtr< T >::operator-> (  )  [inline]

template<class T>
const SmartPtr< T > & OPTPP::SmartPtr< T >::operator= ( const SmartPtr< T > &  rhs  )  [inline]

template<class T>
int OPTPP::SmartPtr< T >::refCount (  )  const [inline]


Member Data Documentation

template<class T>
T* OPTPP::SmartPtr< T >::ptr_ [protected]

template<class T>
int* OPTPP::SmartPtr< T >::refCount_ [protected]


The documentation for this class was generated from the following files:
Bug Reports    OPT++ Developers    Copyright Information    GNU Lesser General Public License
Documentation, generated by , last revised August 30, 2006.