long use_count() const;
Returns the number of different
shared_ptr instances (this included) managing the current object. If there is no managed object, 0 is returned.
 Return value
the number of
shared_ptr instances managing the current object or 0 if there is no managed object.
Common use cases include
- comparison with 0. If
use_countreturns zero, the shared pointer is empty and manages no objects (whether or not its stored pointer is null).
- comparison with 1. If
use_countreturns 1, there are no other owners, which may indicate that the managed object is safe to modify. The member function unique() is provided for this use case.
sp1.use_count() == 1 fun: sp.use_count() == 2
 See also
| checks whether the managed object is managed only by the current |
(public member function)