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 whetheruse_count的 C++ 等效文件是1, you can use member unique instead, which may be faster.

参数



返回值

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

另见