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?
The full specializations of std::atomic for integral types provide arithmetic compound assignment operators such
Share
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 ofstd::atomicwould be mixing at the same level operations that are somehow cheap with very expensive operations.