P4221R2 — Atomic Compare
Maged Michael, Paul McKenney, Michael Wong
SG1
Revisions R3Jul 2026R2Jul 2026R1Jul 2026R0May 2026
This paper proposes adding a `compare_load` member function to `std::atomic<T>` and `std::atomic_ref<T>`, alongside corresponding free functions. This function performs an atomic comparison of the atomic object's value with an expected value, following the same value representation comparison semantics as `compare_exchange_strong`. It updates the expected argument on failure, operating entirely as a pure read without writing a new value to the atomic object.