Skip to content

Instantly share code, notes, and snippets.

@ikavalio
Created October 10, 2017 21:51
Show Gist options
  • Save ikavalio/0f4f81a0505d3b8a2adc91d31378ba4c to your computer and use it in GitHub Desktop.
Save ikavalio/0f4f81a0505d3b8a2adc91d31378ba4c to your computer and use it in GitHub Desktop.
Cstdatomic copy constructor hack
#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