|
Zero
0.1.0
|
A generic RAII guard class. More...
#include <guard.h>
Public Member Functions | |
| guard (T *ptr=nullptr) | |
| guard (guard &other) | |
| guard (guard const &) | |
| guard & | operator= (const guard &) |
| guard & | operator= (guard &other) |
| guard & | operator= (T *ptr) |
| operator T* () | |
| operator T const * () const | |
| T & | operator* () |
| T const & | operator* () const |
| T * | operator-> () |
| T const * | operator-> () const |
| T * | get () |
| T const * | get () const |
| T * | release () |
| Notifies this guard that its services are no longer needed because some other entity has assumed ownership of the pointer. More... | |
| void | done () |
| Notifies this guard that its action should be performed now rather than at destruct time. More... | |
| ~guard () | |
Private Member Functions | |
| void | action (T *ptr) |
| void | assign (T *ptr) |
| template<> | |
| void | action (FILE *ptr) |
Private Attributes | |
| T * | _ptr |
A generic RAII guard class.
This class ensures that the object it encloses will be properly disposed of when it goes out of scope, or with an explicit call to done(), 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.
TODO: make generic and configurable (ie, use templates to determine what "null" and "action" are)
|
inlineprivate |
Notifies this guard that its action should be performed now rather than at destruct time.
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.
1.8.12