fork download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. using namespace std;
  7. int a[] = {1, 2, 3, 4, 5};
  8.  
  9. auto const f = [&](){ for_each(a, a + (sizeof(a) / sizeof(a[0])), [](int i){ cout << i << endl; }); };
  10.  
  11. a[0] = 2;
  12.  
  13. f();
  14. }
  15.  
  16.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
2
2
3
4
5