wxWidgets: wxWindowPtr< T > Class Template Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxWindowPtr< T > Class Template Reference
Class List by Category » Smart Pointers

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-3.x86_64/src/wxWidgets-3.1.5/interface/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

<>< =''>:</>&;&;< =''>\ </></>

Since
  3.0

See also
  wxSharedPtr<T>

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

## Constructor & Destructor Documentation

## ◆ wxWindowPtr() [1/4]

template<typename T>

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

Default constructor.

## ◆ wxWindowPtr() [2/4]

template<typename T>

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

Constructor.

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

## ◆ wxWindowPtr() [3/4]

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.

## ◆ wxWindowPtr() [4/4]

template<typename T>

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

Copy constructor.

## Member Function Documentation

## ◆ operator=() [1/2]

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.

## ◆ operator=() [2/2]

template<typename T>

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

Assignment operator.

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

## ◆ reset()

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.