public member function
<memory>

std::shared_ptr::use_count

long int use_count() const noexcept;
Use count
Returns the number of shared_ptr objects that share ownership over the same pointer as this object (including it).

If this is an empty shared_ptr, the function returns zero.

Library implementations are not required to keep a count of any particular set of owners, and thus it may not be efficient to call this function. To check specifically whether use_count is 1, you can use member unique instead, which may be faster.

Parameters

none

Return value

The number of objects sharing ownership over the same pointer as this.

See also