std::atomic::operators (int)

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.

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.

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

(C++11)
atomically adds the argument to the value stored in the atomic object and obtains the value held previously
(public member function)
(C++11)
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)
doc_CPP
2016-10-11 10:00:26
Comments
Leave a Comment

Please login to continue.