#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. | |
| ~wxScopedPtr () | |
| Destructor deletes the pointer. | |
| T * | get () const |
| Returns pointer to object or nullptr. | |
| 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. | |
| T * | release () |
| Releases the current pointer and returns it. | |
| void | reset (T *ptr=nullptr) |
| Reset pointer to the value of ptr. | |
| void | swap (wxScopedPtr< T > &ot) |
| Swaps pointers. | |
| wxScopedPtr (type *T=nullptr) | |
| Creates the smart pointer with the given pointer or none if nullptr. | |
| ~wxScopedPtr () | |
| Destructor frees the pointer help by this object if it is not nullptr. | |
| T * | get () const |
| This operator gets the pointer stored in the smart pointer or returns nullptr if there is none. | |
| T & | operator* () const |
| This operator works like the standard C++ pointer operator to return the object being pointed to by the pointer. | |
| T * | operator-> () const |
| Smart pointer member access. | |
| T * | release () |
| Returns the currently hold pointer and resets the smart pointer object to nullptr. | |
| reset (T *p=nullptr) | |
| Deletes the currently held pointer and sets it to p or to nullptr if no arguments are specified. | |
| swap (wxScopedPtr &other) | |
| Swap the pointer inside the smart pointer with other. | |
| 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.
|
explicit |
Creates the smart pointer with the given pointer or none if nullptr.
On compilers that support it, this uses the explicit keyword.
| wxScopedPtr::~wxScopedPtr | ( | ) |
Destructor frees the pointer help by this object if it is not nullptr.
| T * wxScopedPtr::get | ( | ) | const |
This operator gets the pointer stored in the smart pointer or returns nullptr if there is none.
| 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::operator* | ( | ) | const |
This operator works like the standard C++ pointer operator to return the object being pointed to by the pointer.
If the internal pointer is nullptr this method will cause an assert in debug mode.
| 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::operator-> | ( | ) | const |
Smart pointer member access.
Returns pointer to its 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::release | ( | ) |
Returns the currently hold pointer and resets the smart pointer object to nullptr.
| T * wxScopedPtr< T >::release | ( | ) |
Releases the current pointer and returns it.
| wxScopedPtr::reset | ( | T * | p = nullptr | ) |
Deletes the currently held pointer and sets it to p or to nullptr if no arguments are specified.
| void wxScopedPtr< T >::reset | ( | T * | ptr = nullptr | ) |
Reset pointer to the value of ptr.
The previous pointer will be deleted.
| wxScopedPtr::swap | ( | wxScopedPtr< T > & | other | ) |
Swap the pointer inside the smart pointer with other.
The pointer being swapped must be of the same type (hence the same class name).
| void wxScopedPtr< T >::swap | ( | wxScopedPtr< T > & | ot | ) |
Swaps pointers.