Inherits std::__shared_ptr< _Tp, _Lp >.
|
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 |
|
|
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 > |
|
|
(Note that these are not member functions.)
|
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) |
|
|
template<typename _Tp , _Lock_policy _Lp> |
bool | atomic_is_lock_free (const __shared_ptr< _Tp, _Lp > *__p) |
|
|
template<typename _Tp > |
shared_ptr< _Tp > | atomic_load_explicit (const shared_ptr< _Tp > *__p, memory_order) |
|
|
template<typename _Tp > |
void | atomic_store_explicit (shared_ptr< _Tp > *__p, shared_ptr< _Tp > __r, memory_order) |
|
|
template<typename _Tp > |
shared_ptr< _Tp > | atomic_exchange_explicit (shared_ptr< _Tp > *__p, shared_ptr< _Tp > __r, memory_order) |
|
|
template<typename _Tp > |
bool | atomic_compare_exchange_strong_explicit (shared_ptr< _Tp > *__p, shared_ptr< _Tp > *__v, shared_ptr< _Tp > __w, memory_order, memory_order) |
|
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.