fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. struct A {
  5. int x = 3;
  6. int y = 4;
  7. };
  8.  
  9. int main() {
  10. A a;
  11. auto r = std::ref(a);
  12. r.get().x = 1;
  13. r.get().y = 2;
  14. std::cout << a.x << ' ' << a.y << std::endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 4328KB
stdin
Standard input is empty
stdout
1 2