cpp/atomic/atomic ref/compare exchange

Atomically compares the value representation of the referenced object with that of, and if those are bitwise-equal, replaces the former with (performs a read-modify-write operation). Otherwise, loads the actual value stored in the referenced object into (performs a load operation).

The memory models for the read-modify-write and load operations are and  respectively. In the (2) and (4) versions is used for both read-modify-write and load operations, except that std and std are used for the load operation if, or  respectively.

Return value
if the referenced object was successfully changed, otherwise.