std::weak_ptr<T>::expired (3) - Linux Manuals
std::weak_ptr<T>::expired: std::weak_ptr<T>::expired
NAME
std::weak_ptr<T>::expired - std::weak_ptr<T>::expired
Synopsis
bool expired() const noexcept; (since C++11)
Equivalent to use_count() == 0. The destructor for the managed object may not yet have been called, but this object's destruction is imminent (or may have already happened).
Parameters
(none)
Return value
true if the managed object has already been deleted, false otherwise.
Notes
This function is inherently racy if the managed object is shared among threads. In particular, a false result may become stale before it can be used. A true result is reliable.
Example
Demonstrates how expired is used to check validity of the pointer.
// Run this code
Output:
See also
lock (public member function)
use_count (public member function)