atomic_exchange Function

Uses Value to replace the stored value of 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;

Parameters

  • Atom
    A pointer to an atomic object that stores a value of type Ty.

  • Value
    A value of type Ty.

Return Value

The stored value of Atom before the exchange.

Remarks

The atomic_exchange function performs a read-modify-write operation to exchange the value that is stored in Atom with Value, using the memory_order_seq_cstmemory_order.

Requirements

Header: atomic

Namespace: std

See Also

Reference

<atomic>

atomic Structure

atomic_exchange_explicit Function