In C++11:
If I increment an atomic variable (operator ++ on std::atomic), is the new value stored with a memory barrier? Or do I have to explicitly do a store?
In C++11: If I increment an atomic variable (operator ++ on std::atomic), is the
Share
You don’t need to do an explicit store. The sequential consistency memory ordering will be used.
operator++(int)andoperator++()onatomic<integral>types are specified to have the effect offetch_add(1), which ends up calling the member function with the default memory orderingmemory_order_seq_cst.For the spec look around Requirements for operations on atomic types [atomics.types.operations.req] 29.6.5/33