P4221R0 — Atomic Compare
Maged Michael, Paul McKenney, Michael Wong
SG1
Revisions R3Jul 2026R2Jul 2026R1Jul 2026R0May 2026
This paper proposes adding `compare` and `compare_load` member functions to `std::atomic<T>`. These functions perform an atomic comparison of the atomic object's value with an expected value, following the same bitwise comparison semantics as `compare_exchange_strong`, but without writing a new value to the atomic object. The `compare_load` variant also updates the expected argument on failure. This paper is ready for review by SG1 in Brno 2026.