|
EA_CPP14_CONSTEXPR | unique_ptr () EA_NOEXCEPT |
|
EA_CPP14_CONSTEXPR | unique_ptr (std::nullptr_t) EA_NOEXCEPT |
|
| unique_ptr (pointer pValue) EA_NOEXCEPT |
|
| unique_ptr (pointer pValue, typename eastl::conditional< eastl::is_lvalue_reference< deleter_type >::value, deleter_type, typename eastl::add_lvalue_reference< const deleter_type >::type >::type deleter) EA_NOEXCEPT |
|
| unique_ptr (pointer pValue, typename eastl::remove_reference< deleter_type >::type &&deleter) EA_NOEXCEPT |
|
| unique_ptr (this_type &&x) EA_NOEXCEPT |
|
template<typename U , typename E > |
| unique_ptr (unique_ptr< U, E > &&u, typename enable_if<!is_array< U >::value &&is_convertible< typename unique_ptr< U, E >::pointer, pointer >::value &&is_convertible< E, deleter_type >::value &&(is_same< deleter_type, E >::value||!is_lvalue_reference< deleter_type >::value)>::type *=0) EA_NOEXCEPT |
|
this_type & | operator= (this_type &&x) EA_NOEXCEPT |
|
template<typename U , typename E > |
enable_if<!is_array< U >::value &&is_convertible< typename unique_ptr< U, E >::pointer, pointer >::value &&is_assignable< deleter_type &, E && >::value, this_type & >::type | operator= (unique_ptr< U, E > &&u) EA_NOEXCEPT |
|
this_type & | operator= (std::nullptr_t) EA_NOEXCEPT |
| operator=(nullptr_t)
|
|
| ~unique_ptr () EA_NOEXCEPT |
|
void | reset (pointer pValue=pointer()) EA_NOEXCEPT |
|
pointer | release () EA_NOEXCEPT |
|
pointer | detach () EA_NOEXCEPT |
|
void | swap (this_type &x) EA_NOEXCEPT |
|
add_lvalue_reference< T >::type | operator* () const |
|
pointer | operator-> () const EA_NOEXCEPT |
|
pointer | get () const EA_NOEXCEPT |
|
deleter_type & | get_deleter () EA_NOEXCEPT |
|
const deleter_type & | get_deleter () const EA_NOEXCEPT |
|
| operator bool () const EA_NOEXCEPT |
|
| unique_ptr (const this_type &)=delete |
| These functions are deleted in order to prevent copying, for safety.
|
|
unique_ptr & | operator= (const this_type &)=delete |
|
unique_ptr & | operator= (pointer pValue)=delete |
|
template<typename T, typename Deleter = eastl::default_delete<T>>
class eastl::unique_ptr< T, Deleter >
class unique_ptr
This class implements a unique_ptr template. This is a class which is similar to the C++ auto_ptr template, except that it prohibits copying of itself, for safety.
More specifically, the unique_ptr class template stores a pointer to a dynamically allocated object. The object pointed to is automatically deleted on destructor of unique_ptr or can be manually deleted via the unique_ptr::reset function.
Memory allocation notes: unique_ptr doesn't allocate memory; all allocated pointers are externally derived. unique_ptr does deallocate memory, though always through the user-provided deleter. You need to make sure you are consistent in providing a deleter which frees memory in a way that matches how it was originally allocated. Deleters have instance information and are moved between containers the same way the allocated pointers are. Thus you can allocate memory via some heap and provide a deleter which contains a pointer to that same heap, and regardless of what you do with the unique_ptr, including moving it to another unique_ptr, the deletion will use the originally provided heap.
Example usage: unique_ptr<int> p(new int); *p = 4;
unique_ptr<int[]> pArray(new int[4]); p[0] = 4;
Type completeness requirements http://stackoverflow.com/questions/6012157/is-stdunique-ptrt-required-to-know-the-full-definition-of-t/6089065#6089065 Here is a table which documents several members of shared_ptr and unique_ptr with respect to completeness requirements. If the member requires a complete type, the entry has a "C", otherwise the table entry is filled with "I".
unique_ptr shared_ptr
+------------------------+---------------+---------------+
| P() | I | I |
| default constructor | | |
+------------------------+---------------+---------------+
| P(const P&) | N/A | I |
| copy constructor | | |
+------------------------+---------------+---------------+
| P(P&&) | I | I |
| move constructor | | |
+------------------------+---------------+---------------+
| ~P() | C | I |
| destructor | | |
+------------------------+---------------+---------------+
| P(A*) | I | C |
+------------------------+---------------+---------------+
| operator=(const P&) | N/A | I |
| copy assignment | | |
+------------------------+---------------+---------------+
| operator=(P&&) | C | I |
| move assignment | | |
+------------------------+---------------+---------------+
| reset() | C | I |
+------------------------+---------------+---------------+
| reset(A*) | C | C |
+------------------------+---------------+---------------+