| Version: 3.0.5

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
wxWindowPtr< T > Class Template Reference
Class List by Category » Smart Pointers

`#include <wx/windowptr.h>`

Inheritance diagram for wxWindowPtr< T >:
[legend]

## Detailed Description

### template<typename T>
class wxWindowPtr< T >

A reference-counted smart pointer for holding wxWindow instances.

This specialization of wxSharedPtr<T> is useful for holding wxWindow-derived objects. Unlike wxSharedPtr<T> or `std::shared_ptr<>`, it doesn't use the delete operator to destroy the value when reference count drops to zero, but calls wxWindow::Destroy() to safely destroy the window.

The template parameter T must be wxWindow or a class derived from it.

##

Library: wxCore
Category: Smart Pointers

Since
  3.0

See also
  wxSharedPtr<T>

## Public Member Functions

| wxWindowPtr ()
| Default constructor. More...
| wxWindowPtr (T *ptr)
| Constructor. More...
template<typename Deleter >
| wxWindowPtr (T *ptr, Deleter d)
| Constructor. More...
| wxWindowPtr (const wxWindowPtr< T > &tocopy)
| Copy constructor. More...
wxWindowPtr< T > & | operator= (T *ptr)
| Assignment operator. More...
wxWindowPtr< T > & | operator= (const wxWindowPtr< T > &tocopy)
| Assignment operator. More...
void | reset (T *ptr=NULL)
| Reset pointer to ptr. More...
Public Member Functions inherited from wxSharedPtr< T >
wxEXPLICIT | wxSharedPtr (T *ptr=NULL)
| Constructor. More...
template<typename Deleter >
wxEXPLICIT | wxSharedPtr (T *ptr, Deleter d)
| Constructor. More...
| wxSharedPtr (const wxSharedPtr< T > &tocopy)
| Copy constructor. More...
| ~wxSharedPtr ()
| Destructor. More...
T * | get () const
| Returns pointer to its object or NULL. More...
| operator unspecified_bool_type () const
| Conversion to a boolean expression (in a variant which is not convertible to anything but a boolean expression). More...
T | operator* () const
| Returns a reference to the object. More...
T * | operator-> () const
| Smart pointer member access. More...
wxSharedPtr< T > & | operator= (T *ptr)
| Assignment operator. More...
wxSharedPtr< T > & | operator= (const wxSharedPtr< T > &tocopy)
| Assignment operator. More...
void | reset (T *ptr=NULL)
| Reset pointer to ptr. More...
template<typename Deleter >
void | reset (T *ptr, Deleter d)
| Reset pointer to ptr. More...
bool | unique () const
| Returns true if this is the only pointer pointing to its object. More...
long | use_count () const
| Returns the number of pointers pointing to its object. More...

## Constructor & Destructor Documentation

template<typename T >

wxWindowPtr< T >::wxWindowPtr | ( |  | ) |

Default constructor.

template<typename T >

wxWindowPtr< T >::wxWindowPtr | ( | T * | ptr | ) |

explicit

Constructor.

Creates shared pointer from the raw pointer ptr and takes ownership of it.

template<typename T >
template<typename Deleter >

wxWindowPtr< T >::wxWindowPtr | ( | T * | ptr,
|  | Deleter | d
| ) |  |

explicit

Constructor.

Creates shared pointer from the raw pointer ptr and deleter d and takes ownership of it.

Parameters

  ptr | The raw pointer.
  d | Deleter - a functor that is called instead of delete to free the ptr raw pointer when its reference count drops to zero.

template<typename T >

wxWindowPtr< T >::wxWindowPtr | ( | const wxWindowPtr< T > & | tocopy | ) |

Copy constructor.

## Member Function Documentation

template<typename T >

wxWindowPtr<T>& wxWindowPtr< T >::operator= | ( | T * | ptr | ) |

Assignment operator.

Releases any previously held pointer and creates a reference to ptr.

template<typename T >

wxWindowPtr<T>& wxWindowPtr< T >::operator= | ( | const wxWindowPtr< T > & | tocopy | ) |

Assignment operator.

Releases any previously held pointer and creates a reference to the same object as topcopy.

template<typename T >

void wxWindowPtr< T >::reset | ( | T * | ptr = `NULL` | ) |

Reset pointer to ptr.

If the reference count of the previously owned pointer was 1 it will be deleted.