|
Zero
0.1.0
|
A generic pointer guard base class. An action will be performed exactly once on the stored pointer, either with an explicit call to done() or when the guard goes out of scope, whichever comes first. More...
#include <guard.h>
Public Types | |
| typedef guard_base_t< T, Impl > | Base |
Public Member Functions | |
| guard_base_t (T obj) | |
| guard_base_t (const guard_base_t &other) | |
| guard_base_t & | operator= (const guard_base_t &other) |
| operator T () const | |
| T | get () const |
| T | release () const |
| Notifies this guard that its services are no longer needed because some other entity has assumed ownership of the pointer. More... | |
| void | done () const |
| Notifies this guard that its action should be performed now rather than at destruct time. More... | |
| ~guard_base_t () | |
Static Public Member Functions | |
| static T | null_value () |
| static bool | different (const T &a, const T &b) |
Protected Member Functions | |
| void | assign (T obj) const |
Protected Attributes | |
| T | _obj |
A generic pointer guard base class. An action will be performed exactly once on the stored pointer, either with an explicit call to done() or when the guard goes out of scope, whichever comes first.
This class is much like the auto_ptr class, other than allowing actions besides delete upon destruct. In particular it is NOT SAFE to use it in STL containers because it does not fulfill the Assignable concept.
This class DOES NOT support being cast as "const" in the traditional sense. Other than disallowing use of the assignment operator '=' it always allows modification of its contents so that it do its job properly. This should not be a problem in practice because a "const T" (with T = <pointer to="" some="" type>="">, eg int*) does not actually protect a pointer's contents from modification anyway. Use T = <pointer to="" some="" const="" type>=""> for that, eg const int*.
| typedef guard_base_t<T, Impl> guard_base_t< T, Impl >::Base |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
inlinestatic |
|
inline |
Notifies this guard that its action should be performed now rather than at destruct time.
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
Notifies this guard that its services are no longer needed because some other entity has assumed ownership of the pointer.
NOTE: this function is marked const so that the assignment operator and copy constructor can work properly.
|
mutableprotected |
1.8.12