Created on 2014-10-01.00:00:00 last changed 88 months ago
Proposed resolution:
This wording is relative to N3936.
Change [util.smartptr.shared.obs] p7-p10 as depicted:
long use_count() const noexcept;-7- Returns: the number of shared_ptr objects, *this included, that share ownership with *this, or 0 when *this is empty.
-8- [Note: use_count() is not necessarily efficient. — end note]bool unique() const noexcept;-9- Returns: use_count() == 1.
-10- [Note:unique() may be faster than use_count().If you are using unique() to implement copy on write, do not rely on a specific value when get() == 0. — end note]
Change [util.smartptr.weak.obs] p1-p4 as depicted:
long use_count() const noexcept;-1- Returns: 0 if *this is empty; otherwise, the number of shared_ptr instances that share ownership with *this.
-2- [Note: use_count() is not necessarily efficient. — end note]bool expired() const noexcept;-3- Returns: use_count() == 0.
-4- [Note: expired() may be faster than use_count(). — end note]
[ Urbana 2014-11-07: Move to Ready ]
shared_ptr and weak_ptr have Notes that their use_count() might be inefficient. This is an attempt to acknowledge reflinked implementations (which can be used by Loki smart pointers, for example). However, there aren't any shared_ptr implementations that use reflinking, especially after C++11 recognized the existence of multithreading. Everyone uses atomic refcounts, so use_count() is just an atomic load.
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2015-05-22 18:31:21 | admin | set | status: ready -> wp |
2014-11-08 16:43:57 | admin | set | messages: + msg7181 |
2014-11-08 16:43:57 | admin | set | status: new -> ready |
2014-10-07 19:50:01 | admin | set | messages: + msg7127 |
2014-10-01 00:00:00 | admin | create |