cptr::atomic_ptr::compare_exchange_weak

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.

Synopsis

Declared in <cptr/pack.hpp>

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