It seems that unlike the member functions, you don’t get to specify which memory_order to use, so there’s probably some ‘default’ that ends up being used.
It seems that unlike the member functions, you don’t get to specify which memory_order
Share
According to the C++ Standard (§29.7/35), the effect of calling
operator++of an atomic typeAwith non-atomic base typeC, i.e. one of these:is the same as that of calling the member function
fetch_add(1), and according to §29.5 (initial declarations), the latter is declared with a default argument:for integral types
C, and:for address types. In other words, the default memory order used by
operator++ismemory_order_seq_cst.The Standard does not make any such statement about
operator+=, although it seems natural to assume that what is true ofoperator++is also true ofoperator+=in this context.Also note there is the general rule for functions of atomic types defined by the Standard: