std::weak_ptr::use_count - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::weak_ptr::use_count

From cppreference.com
< cpp‎ | memory‎ | weak ptr

long use_count() const; |  | (since C++11)

Returns the number of `shared_ptr` instances that share ownership of the managed object, or ​0​ if the managed object has already been deleted, i.e. *this is empty.

### [edit] Parameters

(none)

### [edit] Return value

The number of `shared_ptr` instances sharing the ownership of the managed object.

### [edit] Exceptions

`noexcept` specification:
noexcept

### [edit] Notes

expired() may be faster than `use_count()`.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

expired | checks whether the referenced object was already deleted (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/memory/weak_ptr/use_count&oldid=64191"
Categories:

- unconditionally noexcept
- Todo no example