C++11

// <atomic> 
// 类模板(1)    
template <class T>
    T atomic_exchange
​        (volatile atomic<T>* obj, T val) noexcept;
template <class T>
    T atomic_exchange (atomic<T>* obj, T val) noexcept;
// 重载(2)    
T atomic_exchange (volatile A* obj, T val) noexcept;
T atomic_exchange (A* obj, T val) noexcept;

用一个非原子(Non-atomic)参数原子替换(Atomically replace)指定原子对象的值,并返回该原子对象之前的值。