fork(14) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Test {
  5. mutable int a;
  6. };
  7.  
  8. void testFunc(const Test &test) {
  9. [=] {
  10. test.a = 2;
  11. } ();
  12. }
  13.  
  14. int main() {
  15. Test test{1};
  16. testFunc(test);
  17. cout << (test.a == 2 ? "reference" : "value");
  18. return 0;
  19. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
value