Public Types | Public Member Functions | List of all members
std::unique_ptr< T, D > Class Template Reference

#include <zorba/internal/unique_ptr.h>

Inheritance diagram for std::unique_ptr< T, D >:
Inheritance graph
[legend]

Public Types

typedef D deleter_type
 
typedef T element_type
 
typedef T * pointer
 

Public Member Functions

pointer get () const throw ()
 Gets the pointer. More...
 
deleter_reference get_deleter () throw ()
 Gets the deleter in use. More...
 
deleter_const_reference get_deleter () const throw ()
 Gets the deleter in use. More...
 
 operator explicit_bool::type () const throw ()
 Conversion to bool. More...
 
element_typeoperator* () const throw ()
 Dereferences the pointer. More...
 
pointer operator-> () const throw ()
 Gets the pointer. More...
 
 operator::zorba::internal::rv () throw ()
 
 operator::zorba::internal::rv () const throw ()
 
unique_ptroperator= (zorba::internal::rv< unique_ptr > &p)
 Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr. More...
 
template<typename U , typename E >
unique_ptroperator= (zorba::internal::rv< unique_ptr< U, E > > &p)
 Destructive assignment: moves ownership of the object pointed-to by p to this unique_ptr. More...
 
unique_ptroperator= (int)
 Assignment from null: equivalent to reset(). More...
 
pointer release () throw ()
 Releases ownership of the pointed-to object. More...
 
void reset (pointer p=0) throw ()
 Sets the pointer to the given value or null if none. More...
 
void swap (unique_ptr &p)
 Swaps the pointer and deleter with that of another unique_ptr. More...
 
 unique_ptr (pointer p=0) throw ()
 Default constructor. More...
 
 unique_ptr (pointer p, deleter_reference d)
 Constructs a unique_ptr using a specific deleter. More...
 
 unique_ptr (zorba::internal::rv< unique_ptr > &p)
 Constructs a unique_ptr from an existing unique_ptr. More...
 
template<typename U , typename E >
 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. More...
 
 ~unique_ptr ()
 Destroys the pointed-to object by calling the deleter (if the pointer is not null). More...
 

Detailed Description

template<typename T, class D = default_delete<T>>
class std::unique_ptr< T, D >

Definition at line 202 of file unique_ptr.h.

Member Typedef Documentation

template<typename T, class D = default_delete<T>>
typedef D std::unique_ptr< T, D >::deleter_type

Definition at line 214 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
typedef T std::unique_ptr< T, D >::element_type

Definition at line 212 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
typedef T* std::unique_ptr< T, D >::pointer

Definition at line 213 of file unique_ptr.h.

Constructor & Destructor Documentation

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::unique_ptr ( pointer  p = 0) throw ()
inlineexplicit

Default constructor.

Parameters
pA pointer to the object to point to, if any.

Definition at line 221 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::unique_ptr ( pointer  p,
deleter_reference  d 
)
inline

Constructs a unique_ptr using a specific deleter.

This unique_ptr now has ownership of the pointed-to object.

Parameters
pA pointer to the object to own.
dThe deleter to use.

Definition at line 231 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::unique_ptr ( zorba::internal::rv< unique_ptr< T, D > > &  p)
inline

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 move() function:

unique_ptr<int> a( new int(1) );
unique_ptr<int> b( move(a) ); // ok now
Parameters
pThe unique_ptr to move from.

Definition at line 248 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
template<typename U , typename E >
std::unique_ptr< T, D >::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 
)
inline

Constructs a unique_ptr from an existing unique_ptr.

Template Parameters
UThe pointed-to type such that U* is convertible to T*.
EThe deleter such that E is convertible to D.
Parameters
pThe unique_ptr to move from.

Definition at line 261 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::~unique_ptr ( )
inline

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

Definition at line 279 of file unique_ptr.h.

Member Function Documentation

template<typename T, class D = default_delete<T>>
pointer std::unique_ptr< T, D >::get ( ) const throw ()
inline

Gets the pointer.

Returns
Returns said pointer.

Definition at line 347 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
deleter_reference std::unique_ptr< T, D >::get_deleter ( ) throw ()
inline

Gets the deleter in use.

Returns
Returns said deleter.

Definition at line 356 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
deleter_const_reference std::unique_ptr< T, D >::get_deleter ( ) const throw ()
inline

Gets the deleter in use.

Returns
Returns said deleter.

Definition at line 365 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::operator explicit_bool::type ( ) const throw ()
inline

Conversion to bool.

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

Definition at line 410 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
element_type& std::unique_ptr< T, D >::operator* ( ) const throw ()
inline

Dereferences the pointer.

Returns
Returns a reference to the pointed-to object.

Definition at line 329 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
pointer std::unique_ptr< T, D >::operator-> ( ) const throw ()
inline

Gets the pointer.

Returns
Returns said pointer.

Definition at line 338 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::operator::zorba::internal::rv ( ) throw ()
inline

Definition at line 429 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::operator::zorba::internal::rv ( ) const throw ()
inline

Definition at line 433 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
unique_ptr& std::unique_ptr< T, D >::operator= ( zorba::internal::rv< unique_ptr< T, D > > &  p)
inline

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
pThe unique_ptr to move from.
Returns
Returns *this.

Definition at line 291 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
template<typename U , typename E >
unique_ptr& std::unique_ptr< T, D >::operator= ( zorba::internal::rv< unique_ptr< U, E > > &  p)
inline

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.

Template Parameters
UThe pointed-to type such that U* is convertible to T*.
EThe deleter of p.
Parameters
pThe unique_ptr to move from.
Returns
Returns *this.

Definition at line 308 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
unique_ptr& std::unique_ptr< T, D >::operator= ( int  )
inline

Assignment from null: equivalent to reset().

Returns
Returns *this.

Definition at line 319 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
pointer std::unique_ptr< T, D >::release ( ) throw ()
inline

Releases ownership of the pointed-to object.

Said object will now be the responsibility of the caller.

Returns
Returns a pointer to the object.

Definition at line 375 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
void std::unique_ptr< T, D >::reset ( pointer  p = 0) throw ()
inline

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
pThe new pointer value, if any.

Definition at line 388 of file unique_ptr.h.

Referenced by std::unique_ptr< zorba::Sequence::iterator >::operator=().

template<typename T, class D = default_delete<T>>
void std::unique_ptr< T, D >::swap ( unique_ptr< T, D > &  p)
inline

Swaps the pointer and deleter with that of another unique_ptr.

Parameters
pThe unique_ptr to swap with.

Definition at line 400 of file unique_ptr.h.

Referenced by std::swap().


The documentation for this class was generated from the following file: