atomic_exchange 函式
使用 Value 取代 Atom的儲存值。
template <class _Ty>
inline Ty atomic_exchange(
volatile atomic<Ty> *_Atom,
TyValue
) _NOEXCEPT;
template <class Ty>
inline _Ty atomic_exchange(
atomic<Ty> *Atom,
TyValue
) _NOEXCEPT;
參數
Atom
atomic 物件的指標,該物件儲存指向 Ty 類型的值。Value
型別 Ty 的值。
傳回值
Atom 的儲存值在交換之前。
備註
使用 memory_order_seq_cstmemory_order, atomic_exchange 函式會執行 read-modify-write 作業交換儲存於 Atom 和 Value的值。
需求
**標頭:**atomic
命名空間: std