std::auto_ptr
Defined in header <memory>
|
||
template< class T > class auto_ptr; |
(1) | (deprecated) |
template<> class auto_ptr<void> |
(2) | (deprecated) |
auto_ptr is a smart pointer that manages an object obtained via new and deletes that object when auto_ptr itself is destroyed. It may be used to provide exception safety for dynamically-allocated objects, for passing ownership of dynamically-allocated objects into functions and for returning dynamically-allocated objects from functions.
Copying an auto_ptr copies the pointer and transfers ownership to the destination: both copy construction and copy assignment of auto_ptr modify their right hand arguments, and the "copy" is not equal to the original. Because of these unusual copy semantics, auto_ptr may not be placed in standard containers. std::unique_ptr is preferred for this and other uses.
2) Specialization for type void is provided, it declares the typedef element_type, but no member functions.
Contents |
[edit] Member types
Member type | Definition |
element_type | T |
[edit] Member functions
creates a new auto_ptr (public member function) | |
destroys an auto_ptr and the managed object (public member function) | |
transfers ownership from another auto_ptr (public member function) | |
converts the managed pointer to a pointer to different type (public member function) | |
Modifiers | |
destroys the managed object (public member function) | |
releases ownership of the managed object (public member function) | |
Observers | |
obtains a pointer to the managed object (public member function) | |
accesses the managed object (public member function) |