Public Types | Public Member Functions
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]

List of all members.

Public Types

typedef D deleter_type
typedef T element_type
typedef T * pointer

Public Member Functions

pointer get () const throw ()
 Gets the pointer.
deleter_reference get_deleter () throw ()
 Gets the deleter in use.
deleter_const_reference get_deleter () const throw ()
 Gets the deleter in use.
 operator explicit_bool () const throw ()
 Conversion to bool.
element_typeoperator* () const throw ()
 Dereferences the pointer.
pointer operator-> () const throw ()
 Gets the pointer.
 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.
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.
unique_ptroperator= (int)
 Assignment from null: equivalent to reset().
pointer release () throw ()
 Releases ownership of the pointed-to object.
void reset (pointer p=0) throw ()
 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=0) throw ()
 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.
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.
 ~unique_ptr ()
 Destroys the pointed-to object by calling the deleter (if the pointer is not null).

Detailed Description

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

Definition at line 201 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 215 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 213 of file unique_ptr.h.

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

Definition at line 214 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 222 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 232 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 249 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 262 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 280 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 348 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 357 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 366 of file unique_ptr.h.

template<typename T, class D = default_delete<T>>
std::unique_ptr< T, D >::operator explicit_bool ( ) 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 411 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 330 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 339 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 430 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 434 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 292 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 309 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 320 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 376 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 389 of file unique_ptr.h.

Referenced by std::unique_ptr< proxy_streambuf >::operator=(), and std::unique_ptr< T[], D >::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 401 of file unique_ptr.h.

Referenced by std::unique_ptr< proxy_streambuf >::swap(), std::unique_ptr< T[], D >::swap(), and std::swap().


The documentation for this class was generated from the following file:
blog comments powered by Disqus