std::unique_ptr

#include <zorba/internal/unique_ptr.h>

Private Types

ZORBA_TR1_NS::add_reference< D const >::typedeleter_const_reference
ZORBA_TR1_NS::add_reference< D >::typedeleter_reference
int pointer_conversion::*explicit_bool

Private Attibutes

unique_ptr_storage< T, D >storage_

Public Functions

const inline pointerget()
Gets the pointer.
inline deleter_referenceget_deleter()
Gets the deleter in use.
const inline deleter_const_referenceget_deleter()
Gets the deleter in use.
const inline operator explicit_bool()
Conversion to bool.
const inline element_type &operator*()
Dereferences the pointer.
const inline pointeroperator->()
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 pointerrelease()
Releases ownership of the pointed-to object.
inline voidresetpointer p=0 )
Sets the pointer to the given value or null if none.
inline voidswapunique_ptr & p )
Swaps the pointer and deleter with that of another unique_ptr.
explicit inline unique_ptrpointer p=0 )
Default constructor.
inline unique_ptrpointer p, deleter_reference d )
Constructs a unique_ptr using a specific deleter.
inline unique_ptrzorba::internal::rv< unique_ptr > & p )
Constructs a unique_ptr from an existing unique_ptr.
inline unique_ptrzorba::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 voidcall_deleter()
unique_ptr &operator=unique_ptr &  )
unique_ptr &operator=unique_ptr< U, E > &  )
unique_ptrunique_ptr &  )
unique_ptrunique_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

int pointer_conversion::* explicit_bool

Public Types

deleter_type

D deleter_type

element_type

T element_type

pointer

T * pointer

Private Attibutes

storage_

unique_ptr_storage< T, D > storage_

Public Functions

get

const inline pointer get()

Gets the pointer.

Returns

Returns said pointer.

get_deleter

inline deleter_reference get_deleter()

Gets the deleter in use.

Returns

Returns said deleter.

get_deleter

const inline deleter_const_reference get_deleter()

Gets the deleter in use.

Returns

Returns said deleter.

operator explicit_bool

const inline  operator explicit_bool()

Conversion to bool.

Returns

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

operator*

const inline element_type & operator*()

Dereferences the pointer.

Returns

Returns a reference to the pointed-to object.

operator->

const inline pointer operator->()

Gets the pointer.

Returns

Returns said pointer.

operator::zorba::internal::rv

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

operator::zorba::internal::rv

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

operator=

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.

The object pointed-to by this unique_ptr, if any, is deleted.

Parameters

p

The unique_ptr to move from.

Returns

Returns *this.

operator=

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.

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=

inline unique_ptr & operator=(
    int 
)

Assignment from null: equivalent to .

Returns

Returns *this.

release

inline 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

inline void reset(
    pointer p=0
)

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

inline 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

explicit inline  unique_ptr(
    pointer p=0
)

Default constructor.

Parameters

p

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

unique_ptr

inline  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

inline  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

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.

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

inline  ~unique_ptr()

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

Private Functions

call_deleter

inline 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 > & 
)
blog comments powered by Disqus