atomic<float> only support fetch_and_store but not support fetch_and_add?

atomic<float> only support fetch_and_store but not support fetch_and_add?

The following piece of code runs well:

atomic a;
a = 0.1;
cout< a.fetch_and_store(0.2);
cout<
The following piece does not compile(error: struct tbb::atomic has no member named fetch_and_add):
atomic a;
a = 0.1;
cout< a.fetch_and_store(0.2);
cout< a.fetch_and_add(0.3);
cout<

Anyone know whether current tbb support float/double for fetch_and_add or not?

Thanks!

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

That would be nice and orthogonal, but neither TBB nor C++11 provide arithmetic operations for floating-point types, so they require you to cobble those together yourself (note that with TBB you'll have to be extra careful when evaluating the result of compare_and_swap, as plus zero and minus zero are different bit patterns but compare as equal for the equality operator).

Leave a Comment

Please sign in to add a comment. Not a member? Join today