Smart Interface Pointers

Definition
Library Templates
manual_ptr
shared_ptr
unique_ptr

Definition

Smart 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.

Library Templates

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:

Ownership may be transfered from an lvalue of type unique_ptr using the function template move.


Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah