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.


Derives from


Include files



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.



Destructor frees the pointer help by this object and restores the value stored at the tied location (as specified in the constructor) to the old value.

Warning: this location may now contain an uninitialized value if it hadn't been initialized previously, in particular don't count on it magically being NULL!

ymasuda 平成17年11月19日