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 = [&](){
  10. return [=](){
  11. for_each(a, a + (sizeof(a) / sizeof(a[0])), [](int i){ cout << i << endl; });
  12. };
  13. }();
  14.  
  15. a[0] = 2;
  16.  
  17. f();
  18. }
  19.  
  20.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
1
2
3
4
5