wxWidgets: wxScopedPtr< T > Class Template Reference

| Version: 3.0.5

Public Member Functions | List of all members
wxScopedPtr< T > Class Template Reference
Class List by Category » Smart Pointers

`#include </home/Hamis/wxwidgets/wxWidgets3.0/wxWidgets3.0-3.0.5.1-2.x86_64/src/wxWidgets-3.0.5.1/interface/wx/scopedptr.h>`

## Detailed Description

### template<typename T>
class wxScopedPtr< T >

A scoped pointer template class.

It is the template version of the old-style scoped pointer macros.

Notice that objects of this class intentionally cannot be copied.

##

Library: wxBase

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

See also
  wxSharedPtr<T>, wxWeakRef<T>

## Public Member Functions
| wxScopedPtr (T *ptr=NULL)
| Constructor takes ownership of the pointer. More...
| ~wxScopedPtr ()
| Destructor deletes the pointer. More...
T * | get () const
| Returns pointer to 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...
T * | release ()
| Releases the current pointer and returns it. More...
void | reset (T *ptr=NULL)
| Reset pointer to the value of ptr. More...
void | swap (wxScopedPtr< T > &ot)
| Swaps pointers. More...

## Constructor & Destructor Documentation

## ◆ wxScopedPtr()

template<typename T >

wxScopedPtr< T >::wxScopedPtr | ( | T * | ptr = `NULL` | ) |

Constructor takes ownership of the pointer.

Parameters

  ptr | Pointer allocated with `new` or NULL.

## ◆ ~wxScopedPtr()

template<typename T >

wxScopedPtr< T >::~wxScopedPtr | ( |  | ) |

Destructor deletes the pointer.

## Member Function Documentation

## ◆ get()

template<typename T >

T* wxScopedPtr< T >::get | ( |  | ) | const

Returns pointer to object or NULL.

## ◆ operator unspecified_bool_type()

template<typename T >

wxScopedPtr< T >::operator unspecified_bool_type | ( |  | ) | const

Conversion to a boolean expression (in a variant which is not convertible to anything but a boolean expression).

If this class contains a valid pointer it will return true, if it contains a NULL pointer it will return false.

## ◆ operator*()

template<typename T >

T& wxScopedPtr< T >::operator* | ( |  | ) | const

Returns a reference to the object.

If the internal pointer is NULL this method will cause an assert in debug mode.

## ◆ operator->()

template<typename T >

T* wxScopedPtr< T >::operator-> | ( |  | ) | const

Smart pointer member access.

Returns pointer to object.

If the internal pointer is NULL this method will cause an assert in debug mode.

## ◆ release()

template<typename T >

T* wxScopedPtr< T >::release | ( |  | ) |

Releases the current pointer and returns it.

Remarks
  Afterwards the caller is responsible for deleting the data contained in the scoped pointer before.

## ◆ reset()

template<typename T >

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

Reset pointer to the value of ptr.

The previous pointer will be deleted.

## ◆ swap()

template<typename T >

void wxScopedPtr< T >::swap | ( | wxScopedPtr< T > & | ot | ) |

Swaps pointers.