The full specializations of std::atomic for integral types provide arithmetic compound assignment operators such as +=
, -=
, but no *=
or /=
. The standard states this but as far as I can see there is no reason given. Could someone familiar with the reasoning behind the Atomic Operations Library section shed some light on this?
I think this is related to hardware. Many platforms have atomics to handle +=
but I don't know of any that offers *=
. Implementing this through locking would be simple, but the interface of std::atomic
would be mixing at the same level operations that are somehow cheap with very expensive operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With