This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
compare_exchange
empty pointersSection: 99 [depr.util.smartptr.shared.atomic] Status: C++20 Submitter: Alisdair Meredith Opened: 2017-06-15 Last modified: 2021-02-25
Priority: Not Prioritized
View all other issues in [depr.util.smartptr.shared.atomic].
View all issues with C++20 status.
Discussion:
[util.smartptr.shared.atomic] p35 states that two shared pointers are equivalent if
they store the same pointer value, and share ownership. As empty shared pointers
never share ownership, it is not possible to replace an empty shared pointer using
the atomic compare_exchange
API.
[ 2017-06-26 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
Proposed resolution:
This wording is relative to N4659.
Edit [util.smartptr.shared.atomic] as indicated:
template<class T> bool atomic_compare_exchange_weak_explicit( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w, memory_order success, memory_order failure); template<class T> bool atomic_compare_exchange_strong_explicit( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w, memory_order success, memory_order failure);[…]
-35- Remarks: Twoshared_ptr
objects are equivalent if they store the same pointer value and share ownership, or if they store the same pointer value and both are empty. The weak form may fail spuriously. See 32.6.1.