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

zorba::internal::ztd::explicit_bool

explicit_bool

Private Attributes

unique_ptr_storage< T, D >

storage_

Public Functions

pointer

get() const

Gets the pointer.

deleter_reference

get_deleter()

Gets the deleter in use.

deleter_const_reference

get_deleter() const

Gets the deleter in use.

operator explicit_bool::type() const

Conversion to bool.

element_type &

operator*() const

Dereferences the pointer.

pointer

operator->() const

Gets the pointer.

operator::zorba::internal::rv()

operator::zorba::internal::rv() const

unique_ptr &

operator=(zorba::internal::rv< unique_ptr > &p)

Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr.

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.

unique_ptr &

operator=(int)

Assignment from null: equivalent to .

pointer

release()

Releases ownership of the pointed-to object.

void

reset(pointer p=nullptr)

Sets the pointer to the given value or null if none.

void

swap(unique_ptr &p)

Swaps the pointer and deleter with that of another unique_ptr.

unique_ptr(pointer p=nullptr)

Default constructor.

unique_ptr(pointer p, deleter_reference d)

Constructs a unique_ptr using a specific deleter.

unique_ptr(zorba::internal::rv< unique_ptr > &p)

Constructs a unique_ptr from an existing unique_ptr.

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 *=nullptr)

Constructs a unique_ptr from an existing unique_ptr.

~unique_ptr()

Destroys the pointed-to object by calling the deleter (if the pointer is not null).

Private Functions

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

ZORBA_TR1_NS::add_reference< D const >::type deleter_const_reference

deleter_reference

ZORBA_TR1_NS::add_reference< D >::type deleter_reference

explicit_bool

Public Types

deleter_type

D deleter_type

element_type

T element_type

pointer

T * pointer

Private Attributes

storage_

unique_ptr_storage< T, D > storage_

Public Functions

get

pointer get() const

Gets the pointer.

Returns

Returns said pointer.

get_deleter

deleter_reference get_deleter()

Gets the deleter in use.

Returns

Returns said deleter.

get_deleter

deleter_const_reference get_deleter() const

Gets the deleter in use.

Returns

Returns said deleter.

operator explicit_bool::type

 operator explicit_bool::type() const

Conversion to bool.

Returns

Returns true only if the pointer is not null; false only if the pointer is null.

operator*

element_type & operator*() const

Dereferences the pointer.

Returns

Returns a reference to the pointed-to object.

operator->

pointer operator->() const

Gets the pointer.

Returns

Returns said pointer.

operator::zorba::internal::rv

 operator::zorba::internal::rv()

operator::zorba::internal::rv

 operator::zorba::internal::rv() const

operator=

unique_ptr & operator=(zorba::internal::rv< unique_ptr > &p)

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=

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.

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=

unique_ptr & operator=(int)

Assignment from null: equivalent to .

Returns

Returns *this.

release

pointer 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

void reset(pointer p=nullptr)

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

void swap(unique_ptr &p)

Swaps the pointer and deleter with that of another unique_ptr.

Parameters

p The unique_ptr to swap with.

unique_ptr

 unique_ptr(pointer p=nullptr)

Default constructor.

Parameters

p A pointer to the object to point to, if any.

unique_ptr

 unique_ptr(pointer p, deleter_reference d)

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

 unique_ptr(zorba::internal::rv< unique_ptr > &p)

Constructs a unique_ptr from an existing unique_ptr.

Note that:

  unique_ptr<int> a( new int(1) );
  unique_ptr<int> b( a );           // compile-time error
Instead, you must use the function:
  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

 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 *=nullptr)

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

 ~unique_ptr()

Destroys the pointed-to object by calling the deleter (if the pointer is not null).

Private Functions

call_deleter

void call_deleter()

operator=

unique_ptr & operator=(unique_ptr &)

operator=

unique_ptr & operator=(unique_ptr< U, E > &)

unique_ptr

 unique_ptr(unique_ptr &)

unique_ptr

 unique_ptr(unique_ptr< U, E > &)