fork download
  1. #include <atomic>
  2. #include <iostream>
  3.  
  4. struct Foo
  5. {
  6. int x;
  7. int y;
  8. std::atomic_bool bar;
  9. };
  10.  
  11. int main(int, char**)
  12. {
  13. Foo f1 = {1, 2, {true}};
  14. Foo f2 = {3, 4, {false}};
  15.  
  16. std::cout << "f1 - " << f1.x << " " << f1.y << " "
  17. << (f1.bar.load()?"true":"false") << std::endl;
  18. std::cout << "f2 - " << f2.x << " " << f2.y << " "
  19. << (f2.bar.load()?"true":"false") << std::endl;
  20. }
  21.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
f1 - 1 2 true
f2 - 3 4 false