Why is the volatile qualifier used through out std::atomic?
atomic, c++, c++11, volatile
Solution
Why is the `volatile` qualifier used throughout `std::atomic`?
So that volatile objects can also be atomic. See here:
The relevant quote is
The functions and operations are defined to work with volatile objects, so that variables that should be volatile can also be atomic. The volatile qualifier, however, is not required for atomicity.
Do my `atomic<>` variables need to be `volatile` or not?
No, atomic objects don't have to be volatile.
Problem
From what I've read from Herb Sutter and others you would think that `volatile` and concurrent programming were completely orthogonal concepts, at least as far as C/C++ are concerned. However, in GCC implementation all of `std::atomic`'s member functions have the `volatile` qualifier. The same is true in Anthony Williams's implementation of `std::atomic`. So what's deal, do my `atomic<>` variables need be `volatile` or not?