libstdc++
|
#include <shared_ptr.h>
Inherits std::__weak_ptr< _Tp, _Lp >.
Public Types | |
using | element_type = typename remove_extent< _Tp >::type |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename _Tp > | |
void | swap (weak_ptr< _Tp > &__a, weak_ptr< _Tp > &__b) noexcept |
A non-owning observer for a pointer owned by a shared_ptr.
A weak_ptr provides a safe alternative to a raw pointer when you want a non-owning reference to an object that is managed by a shared_ptr.
Unlike a raw pointer, a weak_ptr can be converted to a new shared_ptr that shares ownership with every other shared_ptr that already owns the pointer. In other words you can upgrade from a non-owning "weak" reference to an owning shared_ptr, without having access to any of the existing shared_ptr objects.
Also unlike a raw pointer, a weak_ptr does not become "dangling" after the object it points to has been destroyed. Instead, a weak_ptr becomes expired and can no longer be converted to a shared_ptr that owns the freed pointer, so you cannot accidentally access the pointed-to object after it has been destroyed.
Definition at line 685 of file bits/shared_ptr.h.
|
inherited |
Definition at line 1636 of file shared_ptr_base.h.
|
inlinenoexcept |
Definition at line 702 of file bits/shared_ptr.h.
|
inlinenoexcept |
Definition at line 708 of file bits/shared_ptr.h.
|
inlinenoexcept |
Definition at line 714 of file bits/shared_ptr.h.
|
inlinenoexceptinherited |
Definition at line 1726 of file shared_ptr_base.h.
|
inlinenoexcept |
Definition at line 748 of file bits/shared_ptr.h.
|
inlinenoexcept |
Definition at line 730 of file bits/shared_ptr.h.
|
inlinenoexcept |
Definition at line 722 of file bits/shared_ptr.h.
|
inlinenoexcept |
Definition at line 741 of file bits/shared_ptr.h.
|
inlinenoexceptinherited |
Definition at line 1731 of file shared_ptr_base.h.
|
inlinenoexceptinherited |
Definition at line 1736 of file shared_ptr_base.h.
|
inlinenoexceptinherited |
Definition at line 1740 of file shared_ptr_base.h.
|
inlinenoexceptinherited |
Definition at line 1744 of file shared_ptr_base.h.
|
inlinenoexceptinherited |
Definition at line 1722 of file shared_ptr_base.h.