std::experimental::atomic_weak_ptr<T>::compare_exchange_strong, std::experimental::atomic_weak_ptr<T>::compare_exchange_weak
Min standard notice:
Atomically compares the underlying weak_ptr in *this with expected, and if they are equivalent, replaces the former with desired (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into expected (performs load operation). The replacement is performed as if by the copy or move assignment operator of weak_ptr, as appropriate.
# Declarations
bool compare_exchange_weak( std::weak_ptr<T>& expected, const std::weak_ptr<T>& desired,
std::memory_order success, std::memory_order failure ) noexcept;
bool compare_exchange_weak( std::weak_ptr<T>& expected, std::weak_ptr<T>&& desired,
std::memory_order success, std::memory_order failure ) noexcept;
bool compare_exchange_weak( std::weak_ptr<T>& expected, const std::weak_ptr<T>& desired,
std::memory_order order = std::memory_order_seq_cst ) noexcept;
bool compare_exchange_weak( std::weak_ptr<T>& expected, std::weak_ptr<T>&& desired,
std::memory_order order = std::memory_order_seq_cst ) noexcept;
bool compare_exchange_strong( std::weak_ptr<T>& expected, const std::weak_ptr<T>& desired,
std::memory_order success, std::memory_order failure ) noexcept;
bool compare_exchange_strong( std::weak_ptr<T>& expected, std::weak_ptr<T>&& desired,
std::memory_order success, std::memory_order failure ) noexcept;
bool compare_exchange_strong( std::weak_ptr<T>& expected, const std::weak_ptr<T>& desired,
std::memory_order order = std::memory_order_seq_cst ) noexcept;
bool compare_exchange_strong( std::weak_ptr<T>& expected, std::weak_ptr<T>&& desired,
std::memory_order order = std::memory_order_seq_cst ) noexcept;
# Parameters
expected: reference to the value expected to be found in the atomic objectdesired: the value to store in the atomic object if it is as expectedsuccess: the memory synchronization ordering for the read-modify-write operation if the comparison succeeds. All values are permittedfailure: the memory synchronization ordering for the load operation if the comparison fails. Cannot be std::memory_order_release or std::memory_order_acq_rel and cannot specify stronger ordering than successorder: the memory synchronization ordering for both operations
# Return value
true if the underlying atomic value was changed, false otherwise.
# Notes
The weak forms (1-4) of the functions are allowed to fail spuriously, that is, act as if *this and expected are not equivalent even when they are. When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms.