Konda.eu

Monthly Archives: May 2014

zoom
No comments

C++ Lambda Expressions

C++ is currently going through some extensive updates started with the new C++11 standard back in 2011. One of the exciting and very powerful new features are anonymous functions also knows as lambdas. You can simply write them inline in your source code and pass them around as function pointers. An example of sorting vector of ints in a descending order:

vector<int> vec = { 10, 1, 5, 6, 7, 3, 5 };

sort(vec.begin(), vec.end(), [](int x, int y) { return x < y; });

Continue reading