manual_ptrshared_ptrunique_ptrSmart interface pointers are similar to ordinary smart pointers with the following difference: while an ordinary smart pointer manages an object of a type specified as a template parameter, a smart interface pointer manages an object of any type implementing an interface specified as a template parameter. As a result, a single smart interface pointer can manage objects of completely unrelated types.
Boost.Interfaces includes three smart reference templates: manual_ptr, unique_ptr and shared_ptr.
manual_ptr
The class template manual_ptr is a smart interface pointer which supports manual resource management. Objects managed by instances of manual_ptr are never freed automatically; instead, manual_ptr allows the programmer to delete the bound object using the member function free.
shared_ptr
The class template shared_ptr is a reference-counted smart interface pointer patterned on the template boost::shared_ptr.
unique_ptr
The class template unique_ptr is a smart interface pointer patterned on the template move_ptr introduced in [Hinnant1] as a safe replacement for std::auto_ptr. It has the following characteristics:
unique_ptr type at any given time.
unique_ptr may be passed to and returned from functions, transfering ownership from the caller to the function in the first case, and from the function to the caller in the second.
unique_ptr may neither be assigned to nor be used to initialize a second instance of a specialization of the template.
Ownership may be transfered from an lvalue of type unique_ptr using the function template move.
Revised 13 Jan, 2005
© Copyright Jonathan Turkanis, 2005. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah