#include <wx/scopedptr.h>
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.
Public Member Functions | |
wxScopedPtr (T *ptr=nullptr) | |
Constructor takes ownership of the pointer. More... | |
~wxScopedPtr () | |
Destructor deletes the pointer. More... | |
T * | get () const |
Returns pointer to object or nullptr. 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=nullptr) |
Reset pointer to the value of ptr. More... | |
void | swap (wxScopedPtr< T > &ot) |
Swaps pointers. More... | |
wxScopedPtr< T >::wxScopedPtr | ( | T * | ptr = nullptr | ) |
Constructor takes ownership of the pointer.
ptr | Pointer allocated with new or nullptr. |
wxScopedPtr< T >::~wxScopedPtr | ( | ) |
Destructor deletes the pointer.
T* wxScopedPtr< T >::get | ( | ) | const |
Returns pointer to object or nullptr.
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 nullptr pointer it will return false.
T& wxScopedPtr< T >::operator* | ( | ) | const |
Returns a reference to the object.
If the internal pointer is nullptr this method will cause an assert in debug mode.
T* wxScopedPtr< T >::operator-> | ( | ) | const |
Smart pointer member access.
Returns pointer to object.
If the internal pointer is nullptr this method will cause an assert in debug mode.
T* wxScopedPtr< T >::release | ( | ) |
Releases the current pointer and returns it.
void wxScopedPtr< T >::reset | ( | T * | ptr = nullptr | ) |
Reset pointer to the value of ptr.
The previous pointer will be deleted.
void wxScopedPtr< T >::swap | ( | wxScopedPtr< T > & | ot | ) |
Swaps pointers.