Atomically store a new value and read the old one.
void* exchange( void* new_value, memory_order order = memory_order_seq_cst) volatile;
- Effects:
Atomically store
new_valuein*thisand retrieve the existing value of*this.- Returns:
The value of
*thisimmediately prior to the store.- Throws:
Nothing.
- Note:
This is an atomic read-modify-write operation for the memory location comprising
*this.
Header
#include <atomic>