#include <refcount.h>
Inheritance diagram for ReferenceCountPtr< T >:


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. | |
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.
1.2.18