Namespaces
Variants
Views
Actions

std::atomic::operator+=,-=,&=,|=,^=

From cppreference.com
< cpp‎ | atomic‎ | atomic
Revision as of 07:38, 5 November 2012 by Cubbi (Talk | contribs)

 
 
 
 

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

<tr class="t-dcl ">

<td >
T operator+=( T arg );
T operator+=( T arg ) volatile;
</td>

<td > (1) </td> <td > (member only of atomic<Integral> template specialization)
(since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
T* operator+=( std::ptrdiff_t arg );
T* operator+=( std::ptrdiff_t arg ) volatile;
</td>

<td > (1) </td> <td > (member only of atomic<T*> template specialization)
(since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
T operator-=( T arg );
T operator-=( T arg ) volatile;
</td>

<td > (2) </td> <td > (member only of atomic<Integral> template specialization)
(since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
T* operator-=( std::ptrdiff_t arg );
T* operator-=( std::ptrdiff_t arg ) volatile;
</td>

<td > (2) </td> <td > (member only of atomic<T*> template specialization)
(since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
T operator&=( T arg );
T operator&=( T arg ) volatile;
</td>

<td > (3) </td> <td > (member only of atomic<Integral> template specialization)
(since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
T operator|=( T arg );
T operator|=( T arg ) volatile;
</td>

<td > (4) </td> <td > (member only of atomic<Integral> template specialization)
(since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
T operator^=( T arg );
T operator^=( T arg ) volatile;
</td>

<td > (5) </td> <td > (member only of atomic<Integral> template specialization)
(since C++11) </td> </tr> Template:ddcl list end

Atomically replaces the current value with the result of computation involving the previous value and arg. The operation is read-modify-write operation.

1) Performs atomic addition. Equivalent to fetch_add(arg).
2) Performs atomic subtraction. Equivalent to fetch_sub(arg).
3) Performs atomic bitwise and. Equivalent to fetch_and(arg).
4) Performs atomic bitwise or. Equivalent to fetch_or(arg).
5) Performs atomic bitwise exclusive or. Equivalent to fetch_xor(arg).

For signed Integral types, arithmetic is defined to use two’s complement representation. There are no undefined results. For T* types, the result may be an undefined address, but the operations otherwise have no undefined behavior.

Contents

Parameters

arg - the argument for the arithmetic operation

Return value

The resulting value.

Exceptions

noexcept specification:  
noexcept
  

Notes

Unlike most compound assignment operators, the compound assignment operators for atomic types do not return a reference to their left-hand arguments. They return a copy of the stored value instead.

See also

Template:cpp/atomic/atomic/dcl list operator arith