std::weak_ptr
std::weak_ptr
Defined in header <memory> | ||
---|---|---|
template< class T > class weak_ptr; | (since C++11) |
std::weak_ptr
is a smart pointer that holds a non-owning ("weak") reference to an object that is managed by std::shared_ptr
. It must be converted to std::shared_ptr
in order to access the referenced object.
std::weak_ptr
models temporary ownership: when an object needs to be accessed only if it exists, and