The C++11 standard includes the wonderful std::atomic<T>, which has member functions like this one:
integral fetch_add(integral, memory_order = memory_order_seq_cst);
However, it seems to be lacking in an add_fetch method. tbb::atomic<T> overloads the += operator to behave like add_and_fetch:
value_type operator+=( D addend ) {
return fetch_and_add(addend)+addend;
}
Through empirical observation, std::atomic<T> behaves the same way, but I cannot find where it says so in the standard or if that is just my STL implementation. Is this behavior guaranteed by the standard?
std::atomic<T>ifTis an integral type, has a memberoperator+=which does the same thing. It is described, along with all other atomic compound assignment operators in§29.6.5/30-32