#include <countedptr.h>
It deletes the object to which it refers when the last CountedPtr that refers to it is destroyed.
Nicolai M. Josuttis (The C++ standard library: a tutorial and reference).
Notes from kindjal:
Definition at line 44 of file countedptr.h.
Public Member Functions | |
| CountedPtr (T *p=0) | |
| Constructor. | |
| ~CountedPtr (void) throw () | |
| Destructor. | |
| CountedPtr (const CountedPtr< T > &p) throw () | |
| Copy pointer (one more owner). | |
| template<typename U> | |
| CountedPtr (const CountedPtr< U > &p) throw () | |
| Copy pointer with static cast (one more owner). | |
| CountedPtr< T > & | operator= (const CountedPtr< T > &p) throw () |
| Assignment (unshare old and share new value). | |
| T & | operator * (void) const throw () |
| Access the value to which the pointer refers. | |
| T * | operator-> (void) const throw () |
| Access the pointer. | |
| T * | get (void) const throw () |
| Get the pointer (mimic std::auto_ptr::get()). | |
Private Member Functions | |
| void | dispose (void) |
| Manage the counter and free memory. | |
Private Attributes | |
| T * | ptr |
| pointer to the value | |
| long * | count |
| shared number of owners | |
Friends | |
| class | CountedPtr |
|
||||||||||
|
Constructor. Initialize pointer with existing pointer. It is required that the pointer p is a return value of new. Definition at line 54 of file countedptr.h. |
|
||||||||||
|
Destructor. Delete value if this was the last owner. Definition at line 66 of file countedptr.h. |
|
||||||||||
|
Copy pointer (one more owner).
Definition at line 76 of file countedptr.h. |
|
||||||||||||||
|
Copy pointer with static cast (one more owner).
Definition at line 88 of file countedptr.h. |
|
||||||||||
|
Manage the counter and free memory.
Definition at line 151 of file countedptr.h. |
|
||||||||||
|
Get the pointer (mimic std::auto_ptr::get()).
Definition at line 139 of file countedptr.h. |
|
||||||||||
|
Access the value to which the pointer refers.
Definition at line 117 of file countedptr.h. |
|
||||||||||
|
Access the pointer.
Definition at line 128 of file countedptr.h. |
|
||||||||||
|
Assignment (unshare old and share new value).
Definition at line 100 of file countedptr.h. |
|
|||||
|
Definition at line 162 of file countedptr.h. |
|
|||||
|
shared number of owners
Definition at line 160 of file countedptr.h. |
|
|||||
|
pointer to the value
Definition at line 159 of file countedptr.h. |
1.3.9.1