std::atomic<T>::operator++,++(int),--,--(int) (3) - Linux Manuals
std::atomic<T>::operator++,++(int),--,--(int): std::atomic<T>::operator++,++(int),--,--(int)
NAME
std::atomic<T>::operator++,++(int),--,--(int) - std::atomic<T>::operator++,++(int),--,--(int)
Synopsis
T operator++() noexcept; (1) (member only of atomic<Integral> template specialization)
T operator++() volatile noexcept; (since C++11)
T* operator++() noexcept; (1) (member only of atomic<T*> template specialization)
T* operator++() volatile noexcept; (since C++11)
T operator++( int ) noexcept; (2) (member only of atomic<Integral> template specialization)
T operator++( int ) volatile noexcept; (since C++11)
T* operator++( int ) noexcept; (2) (member only of atomic<T*> template specialization)
T* operator++( int ) volatile noexcept; (since C++11)
T operator--() noexcept; (3) (member only of atomic<Integral> template specialization)
T operator--() volatile noexcept; (since C++11)
T* operator--() noexcept; (3) (member only of atomic<T*> template specialization)
T* operator--() volatile noexcept; (since C++11)
T operator--( int ) noexcept; (4) (member only of atomic<Integral> template specialization)
T operator--( int ) volatile noexcept; (since C++11)
T* operator--( int ) noexcept; (4) (member only of atomic<T*> template specialization)
T* operator--( int ) volatile noexcept; (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
fetch_add (public member function)
fetch_sub (public member function)
operator+=
operator-= adds, subtracts, or performs bitwise AND, OR, XOR with the atomic value
operator&= (public member function)
operator|=
operator^=