Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Smart Pointers.

#include <boost/tr1/memory.hpp>

or

#include <memory>

The shared_ptr class template stores a pointer to a dynamically allocated object, typically with a C++ new-expression. The object pointed to is guaranteed to be deleted when the last shared_ptr pointing to it is destroyed or reset. For more information refer to the shared_ptr and weak_ptr documentation.

namespace std {
namespace tr1 {

class bad_weak_ptr;

// [2.2.3] Class template shared_ptr
template<class T> class shared_ptr;

// [2.2.3.6] shared_ptr comparisons
template<class T, class U> bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b);
template<class T, class U> bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b);
template<class T, class U> bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b);

// [2.2.3.8] shared_ptr specialized algorithms
template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);

// [2.2.3.9] shared_ptr casts
template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r);
template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r);
template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r);

// [2.2.3.7] shared_ptr I/O
template<class E, class T, class Y>
basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);

// [2.2.3.10] shared_ptr get_deleter
template<class D, class T> D * get_deleter(shared_ptr<T> const& p);

// [2.2.4] Class template weak_ptr
template<class T> class weak_ptr;

// [2.2.4.6] weak_ptr comparison
template<class T, class U> bool operator<(weak_ptr<T> const& a, weak_ptr<U> const& b);

// [2.2.4.7] weak_ptr specialized algorithms
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b);

// [2.2.5] Class enable_shared_from_this
template<class T> class enable_shared_from_this;

} // namespace tr1
} // namespace std

Configuration: Boost.Config should (automatically) define the macro BOOST_HAS_TR1_SHARED_PTR if your standard library implements this part of TR1.

Standard Conformity: There are no known deviations from the standard when using the Boost version of this component.


PrevUpHomeNext