std::atomic_exchange, std::atomic_exchange_explicit

From cppreference.com
< cpp‎ | atomic
Defined in header <atomic>
(1) (since C++11)
template< class T >
T atomic_exchange( std::atomic<T>* obj, T desr );
template< class T >
T atomic_exchange( volatile std::atomic<T>* obj, T desr );
(2) (since C++11)
template< class T >

T atomic_exchange_explicit( std::atomic<T>* obj, T desr,

                            std::memory_order order );
template< class T >

T atomic_exchange_explicit( volatile std::atomic<T>* obj, T desr,

                            std::memory_order order );
1) Atomically replaces the value pointed to by obj with the value of desr and returns the value obj held previously, as if by obj->exchange(desr)
2) Atomically replaces the value pointed to by obj with the value of desr and returns the value obj held previously, as if by obj->exchange(desr, order)

Parameters

obj - pointer to the atomic object to modify
desr - the value to store in the atomic object
order - the memory synchronization ordering for this operation: all values are permitted.

Return value

The value held previously by the atomic object pointed to by obj

Exceptions

noexcept specification:  
noexcept