std::weak_ptr::use_count
long use_count() const; | | (since C++11) |
|---|
返回shared_ptr共享托管对象所有权的实例,或0如果托管对象已被删除,则为*this是空的。
参数
%280%29
返回值
的数目shared_ptr实例在调用的瞬间共享托管对象的所有权。
例外
noexcept规格:
noexcept
注记
expired()可能比use_count()如果托管对象在创建和销毁shared_ptr如果结果与调用线程唯一拥有的副本数量匹配,即为零,则结果是可靠的;任何其他值在使用之前可能会变得陈旧。
例
另见
expired | checks whether the referenced object was already deleted (public member function) |
|---|
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

