My target system has g++ 4.6.3 which supports C++0x (but not C++11). I am using an atomic_int to store a state variable that I access between two threads. However, there doesn't seem to be a not equals operator defined for this type. How do I compare atomic_ints?
Asked
Active
Viewed 235 times
1 Answers
0
You should be able to compare them directly due to atomic_int
's conversion operator. If that's not working then you just have to find a compiler specific work-around. Perhaps if you explicitly cast them or use the load()
member function or atomic_load()
non-member function it will work:
static_cast<int>(a) == static_cast<int>(b)
a.load() == b.load()
atomic_load(&a) == atomic_load(&b)
You should note that this is not an atomic compare of any sort, so make sure you're not trying to do something you shouldn't with this comparison.

bames53
- 86,085
- 15
- 179
- 244