public member function
<atomic>

std::atomic::fetch_xor

T fetch_xor (T val, memory_order sync = memory_order_seq_cst) volatile noexcept;
T fetch_xor (T val, memory_order sync = memory_order_seq_cst) noexcept;
Apply bitwise XOR to contained value
Reads the contained value and replaces it by the result of performing a bitwise XOR (exclusive OR) operation between the read value and val.

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 types.

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

Parameters

val
Value to apply.
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).

Data races

No data races (atomic operation). Memory order specified by argument sync.

Exception safety

No-throw guarantee: never throws exceptions.

See also