C++11 lambda

C++ code posted by Garf
created at 12 Nov 14:41, updated at 12 Nov 14:41

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void test()
{
  int sum = 0;
  auto f = [&sum](int i){ sum += i; };
  std::vector<int> v;

  fill(v);

  for(auto i: v)
  {
    f(i);
  }

  std::cout << "sum of values in v : " << sum << std::endl;
}
214 Bytes in 2 ms with coderay