| Version: 3.3.1

Public Member Functions | List of all members
wxScopedTiedPtr Class Reference
Class List by Category » Smart Pointers

`#include <wx/scopedptr.h>`

Inheritance diagram for wxScopedTiedPtr:
[legend]

## Detailed Description

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.

##

Library: wxBase
Category: 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 nullptr. More...
| ~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. More...
Public Member Functions inherited from wxScopedPtr
| wxScopedPtr (type *T=nullptr)
| Creates the smart pointer with the given pointer or none if nullptr. More...
| ~wxScopedPtr ()
| Destructor frees the pointer help by this object if it is not nullptr. More...
T * | get () const
| This operator gets the pointer stored in the smart pointer or returns nullptr if there is none. More...
T & | operator* () const
| This operator works like the standard C++ pointer operator to return the object being pointed to by the pointer. More...
T * | operator-> () const
| Smart pointer member access. More...
T * | release ()
| Returns the currently hold pointer and resets the smart pointer object to nullptr. More...
| reset (T *p=nullptr)
| Deletes the currently held pointer and sets it to p or to nullptr if no arguments are specified. More...
| swap (wxScopedPtr &other)
| Swap the pointer inside the smart pointer with other. More...

## Constructor & Destructor Documentation

## ◆ wxScopedTiedPtr()

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 nullptr.

## ◆ ~wxScopedTiedPtr()

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.

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 nullptr!