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