std::unique_ptr
#include <zorba/internal/unique_ptr.h>
Private Types
| ZORBA_TR1_NS::add_reference< D const >::type | deleter_const_reference |
| ZORBA_TR1_NS::add_reference< D >::type | deleter_reference |
| int pointer_conversion::* | explicit_bool |
Public Types
| D | deleter_type |
| T | element_type |
| T * | pointer |
Private Attibutes
| unique_ptr_storage< T, D > | storage_ |
Public Functions
| const inline pointer | get() Gets the pointer. |
| inline deleter_reference | get_deleter() Gets the deleter in use. |
| const inline deleter_const_reference | get_deleter() Gets the deleter in use. |
| const inline | operator explicit_bool() Conversion to bool. |
| const inline element_type & | operator*() Dereferences the pointer. |
| const inline pointer | operator->() Gets the pointer. |
| inline | operator::zorba::internal::rv() |
| const inline | operator::zorba::internal::rv() |
| inline unique_ptr & | operator=( zorba::internal::rv< unique_ptr > & p ) Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr. |
| inline unique_ptr & | operator=( zorba::internal::rv< unique_ptr< U, E > > & p ) Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr. |
| inline unique_ptr & | operator=( int ) Assignment from null: equivalent to . |
| inline pointer | release() Releases ownership of the pointed-to object. |
| inline void | reset( pointer p=0 ) Sets the pointer to the given value or null if none. |
| inline void | swap( unique_ptr & p ) Swaps the pointer and deleter with that of another unique_ptr. |
| explicit inline | unique_ptr( pointer p=0 ) Default constructor. |
| inline | unique_ptr( pointer p, deleter_reference d ) Constructs a unique_ptr using a specific deleter. |
| inline | unique_ptr( zorba::internal::rv< unique_ptr > & p ) Constructs a unique_ptr from an existing unique_ptr. |
| inline | unique_ptr( zorba::internal::rv< unique_ptr< U, E > > & p, typename enable_if< ZORBA_TR1_NS::is_convertible< typename unique_ptr< U >::pointer, pointer >::value &&ZORBA_TR1_NS::is_convertible< E, D >::value &&(!ZORBA_TR1_NS::is_reference< D >::value||ZORBA_TR1_NS::is_same< D, E >::value) >::type * =0 ) Constructs a unique_ptr from an existing unique_ptr. |
| inline | ~unique_ptr() Destroys the pointed-to object by calling the deleter (if the pointer is not null). |
Private Functions
| inline void | call_deleter() |
| unique_ptr & | operator=( unique_ptr & ) |
| unique_ptr & | operator=( unique_ptr< U, E > & ) |
| unique_ptr( unique_ptr & ) | |
| unique_ptr( unique_ptr< U, E > & ) |
Private Types
deleter_const_reference
deleter_reference
explicit_bool
Public Types
deleter_type
element_type
pointer
Private Attibutes
storage_
Public Functions
get_deleter
Gets the deleter in use.
Returns
Returns said deleter.
get_deleter
Gets the deleter in use.
Returns
Returns said deleter.
operator explicit_bool
Conversion to bool.
Returns
Returns true only if the pointer is not null; false only if the pointer is null.
operator*
Dereferences the pointer.
Returns
Returns a reference to the pointed-to object.
operator::zorba::internal::rv
operator::zorba::internal::rv
operator=
Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr.
The object pointed-to by this unique_ptr, if any, is deleted.
Parameters
| p |
The unique_ptr to move from. |
Returns
Returns *this.
operator=
Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr.
The object pointed-to by this unique_ptr, if any, is deleted.
Parameters
| U |
The pointed-to type such that U* is convertible to T*. |
| E |
The deleter of p. |
Parameters
| p |
The unique_ptr to move from. |
Returns
Returns *this.
operator=
Assignment from null: equivalent to .
Returns
Returns *this.
release
Releases ownership of the pointed-to object.
Said object will now be the responsibility of the caller.
Returns
Returns a pointer to the object.
reset
Sets the pointer to the given value or null if none.
The previosly pointed-to object, if any, is deleted. However, if p equals the current pointer value, then this function does nothing.
Parameters
| p |
The new pointer value, if any. |
swap
Swaps the pointer and deleter with that of another unique_ptr.
Parameters
| p |
The unique_ptr to swap with. |
unique_ptr
Default constructor.
Parameters
| p |
A pointer to the object to point to, if any. |
unique_ptr
Constructs a unique_ptr using a specific deleter.
This unique_ptr now has ownership of the pointed-to object.
Parameters
| p |
A pointer to the object to own. |
| d |
The deleter to use. |
unique_ptr
Constructs a unique_ptr from an existing unique_ptr.
Note that: unique_ptr<int> a( new int(1) ); Instead, you must use the function:
unique_ptr<int> b( a ); // compile-time error
unique_ptr<int> a( new int(1) );
unique_ptr<int> b( move(a) ); // ok now
Parameters
| p |
The unique_ptr to move from. |
unique_ptr
zorba::internal::rv< unique_ptr< U, E > > & p,
typename enable_if< ZORBA_TR1_NS::is_convertible< typename unique_ptr< U >::pointer, pointer >::value &&ZORBA_TR1_NS::is_convertible< E, D >::value &&(!ZORBA_TR1_NS::is_reference< D >::value||ZORBA_TR1_NS::is_same< D, E >::value) >::type * =0
)
Constructs a unique_ptr from an existing unique_ptr.
Parameters
| U |
The pointed-to type such that U* is convertible to T*. |
| E |
The deleter such that E is convertible to D. |
Parameters
| p |
The unique_ptr to move from. |
~unique_ptr
Destroys the pointed-to object by calling the deleter (if the pointer is not null).