std::shared_ptr< _Tp > Class Template Reference
Utilities » Memory » Pointer Abstractions

`#include <memory>`

Inherits std::__shared_ptr< _Tp, _Lp >.

## Public Types

using | element_type = typename __shared_ptr< _Tp >::element_type
using | weak_type = weak_ptr< _Tp >

## Public Member Functions

constexpr | shared_ptr () noexcept
template<typename _Yp , typename = _Constructible<_Yp*>>
| shared_ptr (_Yp *__p)
template<typename _Yp , typename _Deleter , typename = _Constructible<_Yp*, _Deleter>>
| shared_ptr (_Yp *__p, _Deleter __d)
template<typename _Yp , typename _Deleter , typename _Alloc , typename = _Constructible<_Yp*, _Deleter, _Alloc>>
| shared_ptr (_Yp *__p, _Deleter __d, _Alloc __a)
template<typename _Yp , typename = _Constructible<auto_ptr<_Yp>>>
| shared_ptr (auto_ptr< _Yp > &&__r)
| shared_ptr (const shared_ptr &) noexcept=default
template<typename _Yp , typename = _Constructible<const shared_ptr<_Yp>&>>
| shared_ptr (const shared_ptr< _Yp > &__r) noexcept
template<typename _Yp >
| shared_ptr (const shared_ptr< _Yp > &__r, element_type *__p) noexcept
template<typename _Yp , typename = _Constructible<const weak_ptr<_Yp>&>>
| shared_ptr (const weak_ptr< _Yp > &__r)
template<typename _Deleter >
| shared_ptr (nullptr_t __p, _Deleter __d)
template<typename _Deleter , typename _Alloc >
| shared_ptr (nullptr_t __p, _Deleter __d, _Alloc __a)
constexpr | shared_ptr (nullptr_t) noexcept
| shared_ptr (shared_ptr &&__r) noexcept
template<typename _Yp , typename = _Constructible<shared_ptr<_Yp>>>
| shared_ptr (shared_ptr< _Yp > &&__r) noexcept
template<typename _Yp >
| shared_ptr (shared_ptr< _Yp > &&__r, element_type *__p) noexcept
template<typename _Tp1 , typename >
| shared_ptr (std::auto_ptr< _Tp1 > &&__r)
template<typename _Yp , typename _Del , typename = _Constructible<unique_ptr<_Yp, _Del>>>
| shared_ptr (unique_ptr< _Yp, _Del > &&__r)
element_type * | get () const noexcept
| operator bool () const noexcept
element_type & | operator* () const noexcept
element_type * | operator-> () const noexcept
template<typename _Yp >
_Assignable< auto_ptr< _Yp > > | operator= (auto_ptr< _Yp > &&__r)
shared_ptr & | operator= (const shared_ptr &) noexcept=default
template<typename _Yp >
_Assignable< const shared_ptr< _Yp > & > | operator= (const shared_ptr< _Yp > &__r) noexcept
shared_ptr & | operator= (shared_ptr &&__r) noexcept
template<class _Yp >
_Assignable< shared_ptr< _Yp > > | operator= (shared_ptr< _Yp > &&__r) noexcept
template<typename _Yp , typename _Del >
_Assignable< unique_ptr< _Yp, _Del > > | operator= (unique_ptr< _Yp, _Del > &&__r)
void | reset () noexcept
template<typename _Yp >
_SafeConv< _Yp > | reset (_Yp *__p)
template<typename _Yp , typename _Deleter >
_SafeConv< _Yp > | reset (_Yp *__p, _Deleter __d)
template<typename _Yp , typename _Deleter , typename _Alloc >
_SafeConv< _Yp > | reset (_Yp *__p, _Deleter __d, _Alloc __a)
void | swap (__shared_ptr< _Tp, _Lp > &__other) noexcept
bool | unique () const noexcept
long | use_count () const noexcept
template<typename _Tp1 >
bool | owner_before (__shared_ptr< _Tp1, _Lp > const &__rhs) const noexcept
template<typename _Tp1 >
bool | owner_before (__weak_ptr< _Tp1, _Lp > const &__rhs) const noexcept

## Friends

template<typename _Yp , typename _Alloc >
shared_ptr< _BoundedArray< _Yp > > | allocate_shared (const _Alloc &)
template<typename _Yp , typename _Alloc , typename... _Args>
shared_ptr< _NonArray< _Yp > > | allocate_shared (const _Alloc &, _Args &&...)
template<typename _Yp , typename _Alloc >
shared_ptr< _BoundedArray< _Yp > > | allocate_shared (const _Alloc &, const remove_extent_t< _Yp > &)
template<typename _Yp , typename _Alloc >
shared_ptr< _UnboundedArray< _Yp > > | allocate_shared (const _Alloc &, size_t)
template<typename _Yp , typename _Alloc >
shared_ptr< _UnboundedArray< _Yp > > | allocate_shared (const _Alloc &, size_t, const remove_extent_t< _Yp > &)
template<typename _Yp , typename _Alloc >
shared_ptr< _NotUnboundedArray< _Yp > > | allocate_shared_for_overwrite (const _Alloc &)
template<typename _Yp , typename _Alloc >
shared_ptr< _UnboundedArray< _Yp > > | allocate_shared_for_overwrite (const _Alloc &, size_t)
template<typename _Yp >
shared_ptr< _BoundedArray< _Yp > > | make_shared ()
template<typename _Yp , typename... _Args>
shared_ptr< _NonArray< _Yp > > | make_shared (_Args &&...)
template<typename _Yp >
shared_ptr< _BoundedArray< _Yp > > | make_shared (const remove_extent_t< _Yp > &)
template<typename _Yp >
shared_ptr< _UnboundedArray< _Yp > > | make_shared (size_t)
template<typename _Yp >
shared_ptr< _UnboundedArray< _Yp > > | make_shared (size_t, const remove_extent_t< _Yp > &)
template<typename _Yp >
shared_ptr< _NotUnboundedArray< _Yp > > | make_shared_for_overwrite ()
template<typename _Yp >
shared_ptr< _UnboundedArray< _Yp > > | make_shared_for_overwrite (size_t)
class | weak_ptr< _Tp >

## Related Symbols

(Note that these are not member symbols.)
template<typename _Del , typename _Tp >
_Del * | get_deleter (const shared_ptr< _Tp > &__p) noexcept
template<typename _Ch , typename _Tr , typename _Tp , _Lock_policy _Lp>
std::basic_ostream< _Ch, _Tr > & | operator<< (std::basic_ostream< _Ch, _Tr > &__os, const __shared_ptr< _Tp, _Lp > &__p)
template<typename _Tp , typename _Up >
bool | operator== (const shared_ptr< _Tp > &__a, const shared_ptr< _Up > &__b) noexcept
template<typename _Tp >
bool | operator== (const shared_ptr< _Tp > &__a, nullptr_t) noexcept
template<typename _Tp >
bool | operator== (nullptr_t, const shared_ptr< _Tp > &__a) noexcept
template<typename _Tp , typename _Up >
bool | operator!= (const shared_ptr< _Tp > &__a, const shared_ptr< _Up > &__b) noexcept
template<typename _Tp >
bool | operator!= (const shared_ptr< _Tp > &__a, nullptr_t) noexcept
template<typename _Tp >
bool | operator!= (nullptr_t, const shared_ptr< _Tp > &__a) noexcept
template<typename _Tp , typename _Up >
bool | operator< (const shared_ptr< _Tp > &__a, const shared_ptr< _Up > &__b) noexcept
template<typename _Tp >
bool | operator< (const shared_ptr< _Tp > &__a, nullptr_t) noexcept
template<typename _Tp >
bool | operator< (nullptr_t, const shared_ptr< _Tp > &__a) noexcept
template<typename _Tp , typename _Up >
bool | operator<= (const shared_ptr< _Tp > &__a, const shared_ptr< _Up > &__b) noexcept
template<typename _Tp >
bool | operator<= (const shared_ptr< _Tp > &__a, nullptr_t) noexcept
template<typename _Tp >
bool | operator<= (nullptr_t, const shared_ptr< _Tp > &__a) noexcept
template<typename _Tp , typename _Up >
bool | operator> (const shared_ptr< _Tp > &__a, const shared_ptr< _Up > &__b) noexcept
template<typename _Tp >
bool | operator> (const shared_ptr< _Tp > &__a, nullptr_t) noexcept
template<typename _Tp >
bool | operator> (nullptr_t, const shared_ptr< _Tp > &__a) noexcept
template<typename _Tp , typename _Up >
bool | operator>= (const shared_ptr< _Tp > &__a, const shared_ptr< _Up > &__b) noexcept
template<typename _Tp >
bool | operator>= (const shared_ptr< _Tp > &__a, nullptr_t) noexcept
template<typename _Tp >
bool | operator>= (nullptr_t, const shared_ptr< _Tp > &__a) noexcept
template<typename _Tp >
void | swap (shared_ptr< _Tp > &__a, shared_ptr< _Tp > &__b) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | static_pointer_cast (const shared_ptr< _Up > &__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | const_pointer_cast (const shared_ptr< _Up > &__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | dynamic_pointer_cast (const shared_ptr< _Up > &__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | reinterpret_pointer_cast (const shared_ptr< _Up > &__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | static_pointer_cast (shared_ptr< _Up > &&__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | const_pointer_cast (shared_ptr< _Up > &&__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | dynamic_pointer_cast (shared_ptr< _Up > &&__r) noexcept
template<typename _Tp , typename _Up >
shared_ptr< _Tp > | reinterpret_pointer_cast (shared_ptr< _Up > &&__r) noexcept
template<typename _Tp , typename _Alloc , typename... _Args>
shared_ptr< _NonArray< _Tp > > | allocate_shared (const _Alloc &__a, _Args &&... __args)
template<typename _Tp , typename... _Args>
shared_ptr< _NonArray< _Tp > > | make_shared (_Args &&... __args)
template<typename _Tp , typename _Alloc >
shared_ptr< _UnboundedArray< _Tp > > | allocate_shared (const _Alloc &__a, size_t __n)
template<typename _Tp , typename _Alloc >
shared_ptr< _BoundedArray< _Tp > > | allocate_shared (const _Alloc &__a)

## Detailed Description

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

A smart pointer with reference-counted copy semantics.

Since
  C++11

A `shared_ptr` object is either empty or owns a pointer passed to the constructor. Copies of a `shared_ptr` share ownership of the same pointer. When the last `shared_ptr` that owns the pointer is destroyed or reset, the owned pointer is freed (either by `delete` or by invoking a custom deleter that was passed to the constructor).

A `shared_ptr` also stores another pointer, which is usually (but not always) the same pointer as it owns. The stored pointer can be retrieved by calling the `get()` member function.

The equality and relational operators for `shared_ptr` only compare the stored pointer returned by `get()`, not the owned pointer. To test whether two `shared_ptr` objects share ownership of the same pointer see `std::shared_ptr::owner_before` and `std::owner_less`.

Definition at line 175 of file bits/shared_ptr.h.

## Member Typedef Documentation

## element_type

template<typename _Tp >

using std::shared_ptr< _Tp >::element_type = typename __shared_ptr<_Tp>::element_type

The type pointed to by the stored pointer, remove_extent_t<_Tp>

Definition at line 190 of file bits/shared_ptr.h.

## weak_type

template<typename _Tp >

using std::shared_ptr< _Tp >::weak_type = weak_ptr<_Tp>

The corresponding weak_ptr type for this shared_ptr.

Since
  C++17

Definition at line 196 of file bits/shared_ptr.h.

## Constructor & Destructor Documentation

## shared_ptr() [1/16]

template<typename _Tp >

constexpr std::shared_ptr< _Tp >::shared_ptr | ( |  | ) |

inline constexpr noexcept

Construct an empty shared_ptr.

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

Definition at line 202 of file bits/shared_ptr.h.

## shared_ptr() [2/16]

template<typename _Tp >

std::shared_ptr< _Tp >::shared_ptr | ( | const shared_ptr< _Tp > & |  | ) |

default noexcept

Copy constructor.

## shared_ptr() [3/16]

template<typename _Tp >
template<typename _Yp , typename = _Constructible<_Yp*>>

std::shared_ptr< _Tp >::shared_ptr | ( | _Yp * | __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 214 of file bits/shared_ptr.h.

## shared_ptr() [4/16]

template<typename _Tp >
template<typename _Yp , typename _Deleter , typename = _Constructible<_Yp*, _Deleter>>

std::shared_ptr< _Tp >::shared_ptr | ( | _Yp * | __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.

Requirements: _Deleter's copy constructor and destructor must not throw

__shared_ptr will release __p by calling __d(__p)

Definition at line 231 of file bits/shared_ptr.h.

## shared_ptr() [5/16]

template<typename _Tp >
template<typename _Deleter >

std::shared_ptr< _Tp >::shared_ptr | ( | nullptr_t | __p,
|  | _Deleter | __d
| ) |  |

inline

Construct a shared_ptr that owns a null pointer and the deleter __d.

Parameters

  __p | A null pointer constant.
  __d | A deleter.

Postcondition
  use_count() == 1 && get() == __p

Exceptions

  std::bad_alloc,in | which case __d(__p) is called.

Requirements: _Deleter's copy constructor and destructor must not throw

The last owner will call __d(__p)

Definition at line 248 of file bits/shared_ptr.h.

## shared_ptr() [6/16]

template<typename _Tp >
template<typename _Yp , typename _Deleter , typename _Alloc , typename = _Constructible<_Yp*, _Deleter, _Alloc>>

std::shared_ptr< _Tp >::shared_ptr | ( | _Yp * | __p,
|  | _Deleter | __d,
|  | _Alloc | __a
| ) |  |

inline

Construct a shared_ptr that owns the pointer __p and the deleter __d.

Parameters

  __p | A pointer.
  __d | A deleter.
  __a | An allocator.

Postcondition
  use_count() == 1 && get() == __p

Exceptions

  std::bad_alloc,in | which case __d(__p) is called.

Requirements: _Deleter's copy constructor and destructor must not throw _Alloc's copy constructor and destructor must not throw.

__shared_ptr will release __p by calling __d(__p)

Definition at line 268 of file bits/shared_ptr.h.

## shared_ptr() [7/16]

template<typename _Tp >
template<typename _Deleter , typename _Alloc >

std::shared_ptr< _Tp >::shared_ptr | ( | nullptr_t | __p,
|  | _Deleter | __d,
|  | _Alloc | __a
| ) |  |

inline

Construct a shared_ptr that owns a null pointer and the deleter __d.

Parameters

  __p | A null pointer constant.
  __d | A deleter.
  __a | An allocator.

Postcondition
  use_count() == 1 && get() == __p

Exceptions

  std::bad_alloc,in | which case __d(__p) is called.

Requirements: _Deleter's copy constructor and destructor must not throw _Alloc's copy constructor and destructor must not throw.

The last owner will call __d(__p)

Definition at line 287 of file bits/shared_ptr.h.

## shared_ptr() [8/16]

template<typename _Tp >
template<typename _Yp >

std::shared_ptr< _Tp >::shared_ptr | ( | const shared_ptr< _Yp > & | __r,
|  | element_type * | __p
| ) |  |

inline noexcept

Constructs a `shared_ptr` instance that stores `__p` and shares ownership with `__r`.

Parameters

  __r | A `shared_ptr`.
  __p | A pointer that will remain valid while `*__r` is valid.

Postcondition
  `get() == __p && use_count() == __r.use_count()`

This can be used to construct a `shared_ptr` to a sub-object of an object managed by an existing `shared_ptr`. The complete object will remain valid while any `shared_ptr` owns it, even if they don't store a pointer to the complete object.

shared_ptr<pair<int,int>> pii(new pair<int,int>());
shared_ptr<int> pi(pii, &pii->first);
assert(pii.use_count() == 2);
std::auto_ptr_ref
Definition auto_ptr.h:49

Definition at line 311 of file bits/shared_ptr.h.

## shared_ptr() [9/16]

template<typename _Tp >
template<typename _Yp >

std::shared_ptr< _Tp >::shared_ptr | ( | shared_ptr< _Yp > && | __r,
|  | element_type * | __p
| ) |  |

inline noexcept

Constructs a `shared_ptr` instance that stores `__p` and shares ownership with `__r`.

Parameters

  __r | A `shared_ptr`.
  __p | A pointer that will remain valid while `*__r` is valid.

Postcondition
  `get() == __p && !__r.use_count() && !__r.get()`

Since
  C++17

This can be used to construct a `shared_ptr` to a sub-object of an object managed by an existing `shared_ptr`. The complete object will remain valid while any `shared_ptr` owns it, even if they don't store a pointer to the complete object.

shared_ptr<pair<int,int>> pii(new pair<int,int>());
shared_ptr<int> pi1(pii, &pii->first);
assert(pii.use_count() == 2);
shared_ptr<int> pi2(std::move(pii), &pii->second);
assert(pii.use_count() == 0);
std::move
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Definition move.h:97

Definition at line 339 of file bits/shared_ptr.h.

## shared_ptr() [10/16]

template<typename _Tp >
template<typename _Yp , typename = _Constructible<const shared_ptr<_Yp>&>>

std::shared_ptr< _Tp >::shared_ptr | ( | const shared_ptr< _Yp > & | __r | ) |

inline noexcept

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()

Definition at line 351 of file bits/shared_ptr.h.

## shared_ptr() [11/16]

template<typename _Tp >

std::shared_ptr< _Tp >::shared_ptr | ( | shared_ptr< _Tp > && | __r | ) |

inline noexcept

Move-constructs a shared_ptr instance from __r.

Parameters

  __r | A shared_ptr rvalue.

Postcondition
  *this contains the old value of __r, __r is empty.

Definition at line 359 of file bits/shared_ptr.h.

## shared_ptr() [12/16]

template<typename _Tp >
template<typename _Yp , typename = _Constructible<shared_ptr<_Yp>>>

std::shared_ptr< _Tp >::shared_ptr | ( | shared_ptr< _Yp > && | __r | ) |

inline noexcept

Move-constructs a shared_ptr instance from __r.

Parameters

  __r | A shared_ptr rvalue.

Postcondition
  *this contains the old value of __r, __r is empty.

Definition at line 368 of file bits/shared_ptr.h.

## shared_ptr() [13/16]

template<typename _Tp >
template<typename _Yp , typename = _Constructible<const weak_ptr<_Yp>&>>

std::shared_ptr< _Tp >::shared_ptr | ( | const weak_ptr< _Yp > & | __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 380 of file bits/shared_ptr.h.

## shared_ptr() [14/16]

template<typename _Tp >
template<typename _Yp , typename _Del , typename = _Constructible<unique_ptr<_Yp, _Del>>>

std::shared_ptr< _Tp >::shared_ptr | ( | unique_ptr< _Yp, _Del > && | __r | ) |

inline

Definition at line 395 of file bits/shared_ptr.h.

## shared_ptr() [15/16]

template<typename _Tp >

constexpr std::shared_ptr< _Tp >::shared_ptr | ( | nullptr_t |  | ) |

inline constexpr noexcept

Construct an empty shared_ptr.

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

Definition at line 412 of file bits/shared_ptr.h.

## shared_ptr() [16/16]

template<typename _Tp >
template<typename _Tp1 , typename >

std::shared_ptr< _Tp >::shared_ptr | ( | std::auto_ptr< _Tp1 > && | __r | ) |

inline

Definition at line 327 of file auto_ptr.h.

## Member Function Documentation

## get()

template<typename _Tp , _Lock_policy _Lp>

element_type * std::__shared_ptr< _Tp, _Lp >::get | ( |  | ) | const

inline noexcept inherited

Return the stored pointer.

Definition at line 1665 of file shared_ptr_base.h.

## operator bool()

template<typename _Tp , _Lock_policy _Lp>

std::__shared_ptr< _Tp, _Lp >::operator bool | ( |  | ) | const

inline explicit noexcept inherited

Return true if the stored pointer is not null.

Definition at line 1669 of file shared_ptr_base.h.

## operator*()

template<typename _Tp , _Lock_policy _Lp, bool = is_array<_Tp>::value, bool = is_void<_Tp>::value>

element_type & std::__shared_ptr_access< _Tp, _Lp, bool, bool >::operator* | ( |  | ) | const

inline noexcept inherited

Definition at line 1347 of file shared_ptr_base.h.

## operator->()

template<typename _Tp , _Lock_policy _Lp, bool = is_array<_Tp>::value, bool = is_void<_Tp>::value>

element_type * std::__shared_ptr_access< _Tp, _Lp, bool, bool >::operator-> | ( |  | ) | const

inline noexcept inherited

Definition at line 1354 of file shared_ptr_base.h.

## operator=() [1/5]

template<typename _Tp >
template<typename _Yp >

_Assignable< auto_ptr< _Yp > > std::shared_ptr< _Tp >::operator= | ( | auto_ptr< _Yp > && | __r | ) |

inline

Definition at line 429 of file bits/shared_ptr.h.

## operator=() [2/5]

template<typename _Tp >
template<typename _Yp >

_Assignable< const shared_ptr< _Yp > & > std::shared_ptr< _Tp >::operator= | ( | const shared_ptr< _Yp > & | __r | ) |

inline noexcept

Definition at line 418 of file bits/shared_ptr.h.

## operator=() [3/5]

template<typename _Tp >

shared_ptr & std::shared_ptr< _Tp >::operator= | ( | shared_ptr< _Tp > && | __r | ) |

inline noexcept

Definition at line 438 of file bits/shared_ptr.h.

## operator=() [4/5]

template<typename _Tp >
template<class _Yp >

_Assignable< shared_ptr< _Yp > > std::shared_ptr< _Tp >::operator= | ( | shared_ptr< _Yp > && | __r | ) |

inline noexcept

Definition at line 446 of file bits/shared_ptr.h.

## operator=() [5/5]

template<typename _Tp >
template<typename _Yp , typename _Del >

_Assignable< unique_ptr< _Yp, _Del > > std::shared_ptr< _Tp >::operator= | ( | unique_ptr< _Yp, _Del > && | __r | ) |

inline

Definition at line 454 of file bits/shared_ptr.h.

## owner_before() [1/2]

template<typename _Tp , _Lock_policy _Lp>
template<typename _Tp1 >

bool std::__shared_ptr< _Tp, _Lp >::owner_before | ( | __shared_ptr< _Tp1, _Lp > const & | __rhs | ) | const

inline noexcept inherited

Define an ordering based on ownership.

This function defines a strict weak ordering between two shared_ptr or weak_ptr objects, such that one object is less than the other unless they share ownership of the same pointer, or are both empty.

Definition at line 1699 of file shared_ptr_base.h.

## owner_before() [2/2]

template<typename _Tp , _Lock_policy _Lp>
template<typename _Tp1 >

bool std::__shared_ptr< _Tp, _Lp >::owner_before | ( | __weak_ptr< _Tp1, _Lp > const & | __rhs | ) | const

inline noexcept inherited

Define an ordering based on ownership.

This function defines a strict weak ordering between two shared_ptr or weak_ptr objects, such that one object is less than the other unless they share ownership of the same pointer, or are both empty.

Definition at line 1704 of file shared_ptr_base.h.

## reset() [1/4]

template<typename _Tp , _Lock_policy _Lp>

void std::__shared_ptr< _Tp, _Lp >::reset | ( |  | ) |

inline noexcept inherited

Definition at line 1641 of file shared_ptr_base.h.

## reset() [2/4]

template<typename _Tp , _Lock_policy _Lp>
template<typename _Yp >

_SafeConv< _Yp > std::__shared_ptr< _Tp, _Lp >::reset | ( | _Yp * | __p | ) |

inline inherited

Definition at line 1646 of file shared_ptr_base.h.

## reset() [3/4]

template<typename _Tp , _Lock_policy _Lp>
template<typename _Yp , typename _Deleter >

_SafeConv< _Yp > std::__shared_ptr< _Tp, _Lp >::reset | ( | _Yp * | __p,
|  | _Deleter | __d
| ) |  |

inline inherited

Definition at line 1655 of file shared_ptr_base.h.

## reset() [4/4]

template<typename _Tp , _Lock_policy _Lp>
template<typename _Yp , typename _Deleter , typename _Alloc >

_SafeConv< _Yp > std::__shared_ptr< _Tp, _Lp >::reset | ( | _Yp * | __p,
|  | _Deleter | __d,
|  | _Alloc | __a
| ) |  |

inline inherited

Definition at line 1660 of file shared_ptr_base.h.

## swap()

template<typename _Tp , _Lock_policy _Lp>

void std::__shared_ptr< _Tp, _Lp >::swap | ( | __shared_ptr< _Tp, _Lp > & | __other | ) |

inline noexcept inherited

Exchange both the owned pointer and the stored pointer.

Definition at line 1684 of file shared_ptr_base.h.

## unique()

template<typename _Tp , _Lock_policy _Lp>

bool std::__shared_ptr< _Tp, _Lp >::unique | ( |  | ) | const

inline noexcept inherited

Return true if use_count() == 1.

Definition at line 1674 of file shared_ptr_base.h.

## use_count()

template<typename _Tp , _Lock_policy _Lp>

long std::__shared_ptr< _Tp, _Lp >::use_count | ( |  | ) | const

inline noexcept inherited

If *this owns a pointer, return the number of owners, otherwise zero.

Definition at line 1679 of file shared_ptr_base.h.

## Friends And Related Symbol Documentation

## weak_ptr< _Tp >

template<typename _Tp >

friend class weak_ptr< _Tp >

friend

Definition at line 535 of file bits/shared_ptr.h.

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

- bits/shared_ptr.h
- auto_ptr.h