Home | C-Bits Package Documentation | Project Page |
#include <safe_ptr.h>
Inheritance diagram for cbits::safe_ptr:
Public Methods | |
safe_ptr (T *t) | |
Create a pointer to T. More... | |
safe_ptr (const safe_ptr< T > &r) | |
Copy construct a pointer to T. More... | |
safe_ptr< T > & | operator= (const safe_ptr< T > &r) |
Assign pointer to T. More... | |
bool | operator== (const safe_ptr< T > &r) |
Test for equality to pointer T. More... | |
sync_ptr< T > | operator-> () |
Access member of T. More... | |
T & | operator * () |
Access member of T. More... | |
virtual | ~safe_ptr () |
Destroy reference to T. More... | |
const long | getRefCount () const |
Access number of references. More... | |
bool | operator== (const ref_ptr< T > &r) |
Test for equality to pointer T. More... | |
Protected Attributes | |
T * | _t |
The underlying object. More... | |
long * | _refs |
Number of references to the object. More... |
Instead of:
A* a = new A(...); a->...;use
safe_ptr<A> a( new A(...) ); a->...;
|
Create a pointer to T. This sets the initial reference count to one (1). |
|
Copy construct a pointer to T. This increments the reference count by one (1). |
|
Destroy reference to T. This decrements the reference count by one (1). If no more references remain, the underlying object is deleted. |
|
Access number of references.
|
|
Access member of T. This doesn't affect the reference count. Reimplemented from cbits::ref_ptr. |
|
Access member of T. This doesn't affect the reference count. Reimplemented from cbits::ref_ptr. |
|
Assign pointer to T. This increments the reference count by one (1). |
|
Test for equality to pointer T. This doesn't affect the reference count. |
|
Test for equality to pointer T. This doesn't affect the reference count. |
|
Number of references to the object.
|
|
The underlying object.
|
|
|