public member function
<atomic>

std::atomic::operator++

pre-increment (1)
T operator++() volatile noexcept;
T operator++() noexcept;
post-increment (2)
T operator++ (int) volatile noexcept;
T operator++ (int) noexcept;
Increment container value
Increments the value of the contained value and returns the resulting contained value (1) or the value it had immediately before the operation (2).

The entire operation is atomic: the value cannot be modified between the instant its value is read and the moment it is modified by this function.

This function behaves as if atomic::fetch_add was called with 1 and memory_order_seq_cst as arguments.

The function is only defined in the atomic specializations for integral and pointer types (except for bool).

Parameters

none (the second version overloads the post-increment operator).

Return value

The contained value after (1) or before (2) the call.
T is atomic's template parameter (the type of the contained value).

Data races

No data races (atomic operation). The operation uses sequential consistency (memory_order_seq_cst).

Exception safety

No-throw guarantee: never throws exceptions.

See also