Skip to content

Instantly share code, notes, and snippets.

@shintakezou
Created March 30, 2012 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shintakezou/2255145 to your computer and use it in GitHub Desktop.
Save shintakezou/2255145 to your computer and use it in GitHub Desktop.
lambda in C++11
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
vector<int> array = {1, 2, 3, 4, 5};
int r = accumulate(array.begin(), array.end(), 0,
[](const int& x, const int& y) -> int { return x + y*2; });
cout << r << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment