# shared_ptr Class Template Reference

List of all members.

## Detailed Description

### template<typename _Tp>
class std::tr1::shared_ptr< _Tp >

A smart pointer with reference-counted copy semantics. The object pointed to is deleted when the last shared_ptr pointing to it is destroyed or reset.

Definition at line 473 of file boost_shared_ptr.h.

## Public Types

- typedef _Tp element_type

## Public Member Functions

- _Tp * get () const
- _Reference operator * () const
- operator __unspecified_bool_type () const
- _Tp * operator-> () const
- template<typename _Tp1> shared_ptr & operator= (std::auto_ptr< _Tp1 > &__r)
- template<typename _Tp1> shared_ptr & operator= (const shared_ptr< _Tp1 > &__r)
- template<typename _Tp1, typename _Deleter> void reset (_Tp1 *__p, _Deleter __d)
- template<typename _Tp1> void reset (_Tp1 *__p)
- void reset ()
- template<typename _Tp1> shared_ptr (const shared_ptr< _Tp1 > &__r, __dynamic_cast_tag)
- template<typename _Tp1> shared_ptr (const shared_ptr< _Tp1 > &__r, __const_cast_tag)
- template<typename _Tp1> shared_ptr (const shared_ptr< _Tp1 > &__r, __static_cast_tag)
- template<typename _Tp1> shared_ptr (std::auto_ptr< _Tp1 > &__r)
- template<typename _Tp1> shared_ptr (const weak_ptr< _Tp1 > &__r)
- template<typename _Tp1> shared_ptr (const shared_ptr< _Tp1 > &__r)
- template<typename _Tp1, typename _Deleter> shared_ptr (_Tp1 *__p, _Deleter __d)
- template<typename _Tp1> shared_ptr (_Tp1 *__p)
- shared_ptr ()
- void swap (shared_ptr< _Tp > &__other)
- bool unique () const
- long use_count () const

## Friends

- template<typename _Del> _Del * get_deleter (const shared_ptr &__p)
- template<typename _Tp1> bool operator!= (const shared_ptr &__a, const shared_ptr< _Tp1 > &__b)
- template<typename _Tp1> bool operator< (const shared_ptr &__a, const shared_ptr< _Tp1 > &__b)
- template<typename _Tp1> bool operator== (const shared_ptr &__a, const shared_ptr< _Tp1 > &__b)
- class shared_ptr
- class weak_ptr

## Constructor & Destructor Documentation

shared_ptr | ( |  | ) | `[inline]`

Construct an empty shared_ptr.

Postcondition:
  use_count()==0 && get()==0

Definition at line 484 of file boost_shared_ptr.h.

shared_ptr | ( | _Tp1 * | __p | ) | `[inline, explicit]`

Construct a shared_ptr that owns the pointer p.

Parameters:

  | p | A pointer that is convertible to element_type*.

Postcondition:
  use_count()==1 && get()==p

Exceptions:

  | std::bad_alloc,in | which case `delete` p is called.

Definition at line 493 of file boost_shared_ptr.h.

shared_ptr | ( | _Tp1 * | __p,
|  | _Deleter | __d
| ) | `[inline]`

Construct a shared_ptr that owns the pointer p and the deleter d.

Parameters:

  | p | A pointer.
  | d | A deleter.

Postcondition:
  use_count()==1 && get()==p

Exceptions:

  | std::bad_alloc,in | which case d(p) is called.

Definition at line 515 of file boost_shared_ptr.h.

shared_ptr | ( | const shared_ptr< _Tp1 > & | __r | ) | `[inline]`

If r is empty, constructs an empty shared_ptr; otherwise construct a shared_ptr that shares ownership with r.

Parameters:

  | r | A shared_ptr.

Postcondition:
  get()==r.get() && use_count()==r.use_count()

Exceptions:

  | std::bad_alloc,in | which case

Definition at line 533 of file boost_shared_ptr.h.

shared_ptr | ( | const weak_ptr< _Tp1 > & | __r | ) | `[inline, explicit]`

Constructs a shared_ptr that shares ownership with r and stores a copy of the pointer stored in r.

Parameters:

  | r | A weak_ptr.

Postcondition:
  use_count()==r.use_count()

Exceptions:

  | bad_weak_ptr | when r.expired(), in which case the constructor has no effect.

Definition at line 547 of file boost_shared_ptr.h.

shared_ptr | ( | std::auto_ptr< _Tp1 > & | __r | ) | `[inline, explicit]`

Postcondition:
  use_count()==1 and r.get()==0

Definition at line 560 of file boost_shared_ptr.h.

References auto_ptr::get().

The documentation for this class was generated from the following file:

- boost_shared_ptr.h