Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

ReferenceCountPtr< T > Class Template Reference
[GLT Misc]

Templated reference-counting pointer. More...

#include <refcount.h>

Inheritance diagram for ReferenceCountPtr< T >:

Inheritance graph
[legend]
Collaboration diagram for ReferenceCountPtr< T >:

Collaboration graph
[legend]
List of all members.

Public Methods

 ReferenceCountPtr ()
 Default constructor.

 ReferenceCountPtr (T *obj)
 Constructor.

 ReferenceCountPtr (const ReferenceCountPtr &ptr)
 Copy constructor.

 ~ReferenceCountPtr ()
 Destructor.

ReferenceCountPtr & operator= (const ReferenceCountPtr &ptr)
 Assignment operator.

void clear ()
 Reset the pointer.

void reset ()
 Reset the pointer.

T & operator * ()
 Dereference the pointer.

T * operator-> ()
 Dereference the pointer.

T * get ()
 Dereference the pointer.

const T & operator * () const
 Dereference the pointer.

const T * operator-> () const
 Dereference the pointer.

const T * get () const
 Dereference the pointer.


Detailed Description

template<class T>
class ReferenceCountPtr< T >

Templated reference-counting pointer.

Dynamically allocated objects (created via 'new') that are managed via ReferenceCountPtr are automatically destroyed when the last pointer is destroyed. Therefore, a reference-counted object can be shared in different places in the system and will not be leaked or a dangling (invalid) pointer.

A count of the number of pointers to the object is maintained, and when this count reaches zero, the object is destroyed.

In a way, ReferenceCountPtr is a safer version of std::auto_ptr.

Definition at line 58 of file refcount.h.


The documentation for this class was generated from the following file:
Generated on Tue Nov 5 11:11:49 2002 for GLT by doxygen1.2.18