std::atomic<T>::operator++,++(int),--,--(int)

From cppreference.com
< cpp‎ | atomic‎ | atomic
 
 
 
 
T operator++() noexcept;
T operator++() volatile noexcept;
(1) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator++() noexcept;
T* operator++() volatile noexcept;
(1) (member only of atomic<T*> template specialization)
(since C++11)
T operator++( int ) noexcept;
T operator++( int ) volatile noexcept;
(2) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator++( int ) noexcept;
T* operator++( int ) volatile noexcept;
(2) (member only of atomic<T*> template specialization)
(since C++11)
T operator--() noexcept;
T operator--() volatile noexcept;
(3) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator--() noexcept;
T* operator--() volatile noexcept;
(3) (member only of atomic<T*> template specialization)
(since C++11)
T operator--( int ) noexcept;
T operator--( int ) volatile noexcept;
(4) (member only of atomic<Integral> template specialization)
(since C++11)
T* operator--( int ) noexcept;
T* operator--( int ) volatile noexcept;
(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. The program is ill-formed if T is not an object type.

Parameters

(none)

Return value

1,3) The value of the atomic variable after the modification. Formally, the result of incrementing/decrementing the value immediately preceding the effects of this function in the modification order of *this.
2,4) The value of the atomic variable before the modification. Formally, the value immediately preceding the effects of this function in the modification order of *this.

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.

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
P0558R1 C++11 arithmetic permitted on pointers to cv void or function made ill-formed

See also

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