#include <wx/scopedptr.h>
This is a variation on the topic of wxScopedPtr.
This class is also a smart pointer but in addition it "ties" the pointer value to another variable. In other words, during the life time of this class the value of that variable is set to be the same as the value of the pointer itself and it is reset to its old value when the object is destroyed. This class is especially useful when converting the existing code (which may already store the pointers value in some variable) to the smart pointers.
Public Member Functions | |
wxScopedTiedPtr (T **ppTie, T *ptr) | |
Constructor creates a smart pointer initialized with ptr and stores ptr in the location specified by ppTie which must not be NULL. | |
~wxScopedTiedPtr () | |
Destructor frees the pointer help by this object and restores the value stored at the tied location (as specified in the wxScopedTiedPtr() constructor) to the old value. | |
Public Member Functions inherited from wxScopedPtr | |
wxScopedPtr (type *T=NULL) | |
Creates the smart pointer with the given pointer or none if NULL. | |
~wxScopedPtr () | |
Destructor frees the pointer help by this object if it is not NULL. | |
T * | get () const |
This operator gets the pointer stored in the smart pointer or returns NULL if there is none. | |
T & | operator* () const |
This operator works like the standard C++ pointer operator to return the object being pointed to by the pointer. | |
T * | operator-> () const |
Smart pointer member access. | |
T * | release () |
Returns the currently hold pointer and resets the smart pointer object to NULL. | |
reset (T *p=NULL) | |
Deletes the currently held pointer and sets it to p or to NULL if no arguments are specified. | |
swap (wxScopedPtr &other) | |
Swap the pointer inside the smart pointer with other. | |
wxScopedTiedPtr::wxScopedTiedPtr | ( | T ** | ppTie, |
T * | ptr | ||
) |
Constructor creates a smart pointer initialized with ptr and stores ptr in the location specified by ppTie which must not be NULL.
wxScopedTiedPtr::~wxScopedTiedPtr | ( | ) |
Destructor frees the pointer help by this object and restores the value stored at the tied location (as specified in the wxScopedTiedPtr() constructor) to the old value.