initialization of atomic variables in c++0x
Can atomic variables in c++0x be initialized globally?
For e.g.
atomic_int turnX = 5;
i开发者_开发百科nt main(){
....
}
fails with error: deleted function ‘std::atomic::atomic(const std::atomic&)’
looking at atomic_2.h does give an idea that this is not allowed. Am I correct in making a statement that atomic variables can be assigned values only from within a function?
try:
atomic_int turnX(5);
This is a constexpr constructor so it should be constructed as constant initialization (i.e. at load time).
精彩评论