Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | atomic‎ | atomic
Revision as of 21:47, 31 May 2013 by P12bot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 
 
 
 
T operator++();
T operator++() volatile;
(1) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator++();
T* operator++() volatile;
(1) (member only of atomic<T*> template specialization)
(since C++11)
T operator++( int );
T operator++( int ) volatile;
(2) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator++( int );
T* operator++( int ) volatile;
(2) (member only of atomic<T*> template specialization)
(since C++11)
T operator--();
T operator--() volatile;
(3) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator--();
T* operator--() volatile;
(3) (member only of atomic<T*> template specialization)
(since C++11)
T operator--( int );
T operator--( int ) volatile;
(4) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator--( int );
T* operator--( int ) volatile;
(4) (member only of atomic<T*> template specialization)
(since C++11)

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

[edit] Parameters

(none)

[edit] Return value

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

[edit] Exceptions

noexcept specification:  
noexcept
  

[edit] 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.

[edit] See also

(C++11)
atomically adds the argument to the value stored in the atomic object and obtains the value held previously
(public member function) [edit]
(C++11)
atomically subtracts the argument from the value stored in the atomic object and obtains the value held previously
(public member function) [edit]
adds, subtracts, or performs bitwise AND, OR, XOR with the atomic value
(public member function) [edit]