fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int i = 0;
  6. int& ref = i;
  7.  
  8. auto f1 = [ref]() mutable { ++ref; };
  9. auto f2 = [&ref](){ ++ref; };
  10.  
  11. f1();
  12. f2();
  13. std::cout << i;
  14. }
  15.  
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
1