GClasses
|
This class is very similar to the standard C++ class auto_ptr, except it throws an exception if you try to make a copy of it. This way, it will fail early if you use it in a manner that could result in non-deterministic behavior. (For example, if you create a vector of auto_ptrs, wierd things happen if an oom exception is thrown while resizing the buffer–part of the data will be lost when it reverts back to the original buffer. But if you make a vector of these, it will fail quickly, thus alerting you to the issue.)
#include <GHolders.h>
Public Member Functions | |
Holder (T *p=NULL) | |
~Holder () | |
Deletes the object that is being held. More... | |
T * | get () |
Returns a pointer to the object being held. More... | |
T & | operator* () const |
T * | operator-> () const |
T * | release () |
Releases the object. (After calling this method, it is your job to delete the object.) More... | |
void | reset (T *p=NULL) |
Deletes the object that is being held, and sets the holder to hold p. Will not delete the held pointer if the new pointer is the same. More... | |
|
inline |
|
inline |
Deletes the object that is being held.
|
inline |
Returns a pointer to the object being held.
|
inline |
|
inline |
|
inline |
Releases the object. (After calling this method, it is your job to delete the object.)
|
inline |
Deletes the object that is being held, and sets the holder to hold p. Will not delete the held pointer if the new pointer is the same.