Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Something {
- public:
- int value;
- };
- auto&& pointer = std::atomic<Something*>{nullptr};
- // thread 1
- auto value = Something{1};
- pointer.set(&value, std::memory_order_relaxed);
- // thread 2
- Something* something = nullptr;
- while (!(something = pointer.load(std::memory_order_relaxed))) {}
- cout << something.value << endl;
Add Comment
Please, Sign In to add comment