![]() |
Murl Engine API
Version 2018.3
|
A simple smart pointer providing strict ownership semantics. More...
#include <murl_auto_pointer.h>
A simple smart pointer providing strict ownership semantics.
An AutoPointer owns the object it holds a pointer to. Copying an AutoPointer copies the pointer and transfers ownership to the destination. If more than one AutoPointer owns the same object at the same time the behavior of the program is undefined.
The uses of AutoPointer include providing passing ownership of dynamically allocated memory to a function and returning dynamically allocated memory from a function.
Public Types | |
typedef Type1 | ValueType |
The template parameter value type. More... | |
Public Member Functions | |
AutoPointer () | |
The default constructor. More... | |
AutoPointer (Type1 *pointer) | |
Constructor taking ownership of a memory location. More... | |
AutoPointer (const AutoPointer &autoPointer) | |
Copy constructor. More... | |
template<class Type2 > | |
AutoPointer (const AutoPointer< Type2 > &autoPointer) | |
Constructor for automatic downcast. More... | |
AutoPointer & | operator= (const AutoPointer &autoPointer) |
Assignment operator. More... | |
template<class Type2 > | |
AutoPointer & | operator= (const AutoPointer< Type2 > &autoPointer) |
Assignment operator for an object of different type. More... | |
~AutoPointer () | |
The destructor. More... | |
Bool | IsNull () const |
Check if the memory pointer is null. More... | |
Type1 & | operator* () const |
Indirection operator. More... | |
Type1 * | operator-> () const |
Dereference operator. More... | |
Type1 * | Get () const |
Get the pointer to the memory. More... | |
Type1 * | Release () |
Release the memory pointer. More... | |
void | Reset (Type1 *pointer=0) |
Take ownership of a memory location. More... | |
template<class Type2 > | |
operator AutoPointer< Type2 > () | |
Conversion operator. More... | |
AutoPointer (AutoPointerRef< Type1 > autoPointerRef) | |
Automatic conversions. More... | |
typedef Type1 Murl::AutoPointer< Type1 >::ValueType |
The template parameter value type.
|
inlineexplicit |
The default constructor.
Set a null pointer.
|
inlineexplicit |
Constructor taking ownership of a memory location.
pointer | The memory to take the ownership from. |
|
inline |
Copy constructor.
Release() the memory pointer in the const autoPointer.
autoPointer | The AutoPointer object to transfer. |
|
inlineexplicit |
Constructor for automatic downcast.
Release() the memory pointer in the const autoPointer.
autoPointer | The AutoPointer object to transfer. |
|
inline |
The destructor.
Free (delete) the memory.
|
inline |
Automatic conversions.
These operations convert an AutoPointer into and from an AutoPointerRef automatically as needed. This allows constructs such as:
autoPointerRef | The AutoPointer object to transfer. |
|
inline |
Assignment operator.
Release() the memory pointer in the const autoPointer.
autoPointer | The AutoPointer object to transfer. |
|
inline |
Assignment operator for an object of different type.
Release() the memory pointer in the const autoPointer.
autoPointer | The AutoPointer object to transfer. |
|
inline |
Check if the memory pointer is null.
|
inline |
Indirection operator.
|
inline |
Dereference operator.
|
inline |
Get the pointer to the memory.
|
inline |
Release the memory pointer.
The receiver of the memory returned takes the ownership. The memory pointer of this object is set to 0.
|
inline |
Take ownership of a memory location.
If the object already owns a memory, the memory is deleted.
pointer | The memory to take the ownership from. |
|
inline |
Conversion operator.
Transfer the memory ownership to an object of different type.