cptr::atomic_ptr::compare_exchange_weak

compare_exchange_weak overloads

Synopses

Declared in <cptr/pack.hpp>

compare_exchange_weak() with one order, from which the failure order is derived as std::atomic does.

bool
compare_exchange_weak(
    T*& expected,
    T* desired,
    std::memory_order order = std::memory_order_seq_cst) noexcept;
» more...

If the pointer equals expected, replaces it with desired and returns true; otherwise loads it into expected and returns false. As std::atomic, the weak form may fail spuriously, so call it in a loop. The comparison is on the compressed offsets, which is the same as on the addresses.

bool
compare_exchange_weak(
    T*& expected,
    T* desired,
    std::memory_order success,
    std::memory_order failure) noexcept;
» more...