Automatic Pointer [deprecated]
Note: This class template is deprecated as of C++11 and completely removed in c++ 17.
unique_ptr is a new facility with a similar functionality, but with improved
security (no fake copy assignments), added features (deleters) and support for
arrays.
auto_ptr objects have the uniqueness of taking ownership of
the pointers allotted to them: An auto_ptr object that has ownership over one
element is in charge of destroying the element it points to and to deallocate
the memory allocated to it when itself is destroyed. The destructor does this
by invoking operator delete automatically.
Hence, no two auto_ptr objects should own the same element,
since together would try to destruct them at some point. When an assignment
operation takes place between two auto_ptr objects, ownership is transferred,
which means that the object losing ownership is set to no longer point to the
element (it is set to the null pointer).
Comments
Post a Comment