Class template unique_ptrboost::interprocess::unique_ptr Synopsistemplate<typename T, typename D> class unique_ptr { public: // types typedef T element_type; typedef D deleter_type; typedef unspecified pointer; // construct/copy/destruct unique_ptr(); unique_ptr(pointer); unique_ptr(pointer, unspecified); unique_ptr(unspecified); template<typename U, typename E> unique_ptr(unspecified, unspecified = nat()); unique_ptr& operator=(unspecified); template<typename U, typename E> unique_ptr& operator=(unspecified); unique_ptr& operator=(int nat::*); ~unique_ptr(); // public member functions unspecified operator*() const; pointer operator->() const; pointer get() const; deleter_reference get_deleter() ; deleter_const_reference get_deleter() const; operator int nat::*() const; pointer release() ; void reset(pointer = 0) ; void swap(unique_ptr &) ; void swap(unspecified) ; }; DescriptionTemplate unique_ptr stores a pointer to an object and deletes that object using the associated deleter when it is itself destroyed (such as when leaving block scope. The unique_ptr provides a semantics of strict ownership. A unique_ptr owns the object it holds a pointer to. A unique_ptr is not CopyConstructible, nor CopyAssignable, however it is MoveConstructible and Move-Assignable. The uses of unique_ptr include providing exception safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function A client-supplied template argument D must be a function pointer or functor for which, given a value d of type D and a pointer ptr to a type T*, the expression d(ptr) is valid and has the effect of deallocating the pointer as appropriate for that deleter. D may also be an lvalue-reference to a deleter. If the deleter D maintains state, it is intended that this state stay with the associated pointer as ownership is transferred from unique_ptr to unique_ptr. The deleter state need never be copied, only moved or swapped as pointer ownership is moved around. That is, the deleter need only be MoveConstructible, MoveAssignable, and Swappable, and need not be CopyConstructible (unless copied into the unique_ptr) nor CopyAssignable.
|