Adds val to the contained value and returns the value it had immediately before the operation.

The entire operation is atomic (an atomic read-modify-write operation): the value is not affected by other threads between the instant its value is read (to be returned) and the moment it is modified by this function.

This member function is only defined in the atomic specializations for integral (1) and pointer (2) types.

If the default value is used for the second argument, this function is equivalent to atomic::operator+=.

Parameters

val

Value to add.T is atomic's template parameter (the type of the contained value).ptrdiff_t is a signed integral type.

sync

Synchronization mode for the operation.
This shall be one of the values of the enum type memory_order.

Return value

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