Namespaces
Variants
Views
Actions

std::atomic::exchange

From cppreference.com
< cpp‎ | atomic‎ | atomic
Revision as of 16:53, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
 

Template:ddcl list begin <tr class="t-dcl ">

<td >
T exchange( T desired, memory_order = std::memory_order_seq_cst );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
T exchange( T desired, memory_order = std::memory_order_seq_cst ) volatile;
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

Atomically replaces the underlying value with desired. The operation is read-modify-write operation. Memory is affected according to the value of memory_order.

Contents

Parameters

desired - value to assign
memory_order - memory order constraints to enforce

Return value

The value of the atomic variable before the call.

Exceptions

noexcept specification:  
noexcept
  

See also

Template:cpp/atomic/dcl list atomic exchange