table of contents
- Tumbleweed 2026.11.13-1.1
- Leap-16.0
- Leap-15.6
| std::atomic_ref::exchange(3) | C++ Standard Libary | std::atomic_ref::exchange(3) |
NAME¶
std::atomic_ref::exchange - std::atomic_ref::exchange
Synopsis¶
value_type exchange( value_type desired,
std::memory_order order = (constexpr since C++26)
std::memory_order_seq_cst ) const noexcept;
Atomically replaces the value of the referenced object with desired. The operation is a read-modify-write operation. Memory is affected according to the value of order.
This overload participates in overload resolution only if std::is_const_v<T> is false.
Parameters¶
desired - value to assign order - memory order constraints to enforce
Return value¶
The value of the referenced object before the call.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 3508 C++20 exchange
was meaningless for const constrained to accept only (P3323R1) T non-const
T
| 2026.11.10 | http://cppreference.com |