Namespaces
Variants
Views
Actions

std::atomic::operator++,++(int),--,--(int)

From cppreference.com
< cpp‎ | atomic‎ | atomic
Revision as of 08:21, 20 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 operator++() 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++();
T* operator++() 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++( int );
T operator++( int ) 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++( int );
T* operator++( int ) 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 operator--() 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* operator--() volatile;
</td>

<td > (3) </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--( int );
T operator--( int ) 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--( int );
T* operator--( int ) volatile;
</td>

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

Atomically increments or decrements the current value. The operation is read-modify-write operation.

1) Performs atomic pre-increment. Equivalent to fetch_add(1)+1.
2) Performs atomic post-increment. Equivalent to fetch_add(1).
3) Performs atomic pre-decrement. Equivalent to fetch_sub(1)-1
4) Performs atomic post-decrement. Equivalent to fetch_sub(1).

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

(none)

Return value

1,3) The value of the atomic variable after the modification.
2,4) The value of the atomic variable before the modification.

Exceptions

noexcept specification:  
noexcept
  

Notes

Unlike most pre-increment and pre-decrement operators, the pre-increment and pre-decrement operators for atomic types do not return a reference to the modified object. They return a copy of the stored value instead.

See also

Template:cpp/atomic/atomic/dcl list fetch addTemplate:cpp/atomic/atomic/dcl list fetch subTemplate:cpp/atomic/atomic/dcl list operator arith2