Created
October 10, 2017 21:51
-
-
Save ikavalio/0f4f81a0505d3b8a2adc91d31378ba4c to your computer and use it in GitHub Desktop.
Cstdatomic copy constructor hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if __GNUC__ == 4 && __GNUC_MINOR__ < 6 | |
#include <cstdatomic> | |
#else | |
#include <atomic> | |
#endif | |
#include <vector> | |
struct S { | |
std::atomic_int a; | |
S() : a(0) {} | |
#ifdef COPY | |
S(const S& s) : a(s.a.load()) {} | |
#endif | |
}; | |
int main() { | |
std::vector<S> v(10); | |
v[0].a.store(1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment