This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
std::atomic<> for double
- From: niXman <i dot nixman at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 21 Apr 2012 13:05:54 +0400
- Subject: std::atomic<> for double
Hello!
where is a code that compiles and works as expected:
#include <atomic>
#include <iostream>
int main() {
std::atomic<int> i(0);
i += 3;
std::cout << i << std::endl;
}
http://liveworkspace.org/code/eb92d1706687414dd3f49976584ff337
now change it to type double:
#include <atomic>
#include <iostream>
int main() {
std::atomic<double> i(0);
i += 3.14;
std::cout << i << std::endl;
}
http://liveworkspace.org/code/555191936a23b06352220ff11b1e33df
and get the following error:
> source.cpp: In function 'int main()':
> source.cpp:6:9: error: no match for 'operator+=' in 'i += 3.1400000000000001e+0'
therefore, I have two questions:
1. Ñan double be actually an atomic type?
2. how is supposed to use atomic <double> by standard?
Thanks!
--
Regards,
 niXman