Quick Q: What is a lambda expression in C++11?
▻http://isocpp.org/feeder/?FeederAction=clicked&feed=All+Posts&seed=http%3A%2F%2Fisocpp.org%2Fblog%2F2
Quick A: A convenient way to create a functor.
Recently on SO:
What is a lambda expression in C++11? C++ includes useful generic functions like std::for_each and std::transform, which can be very handy. Unfortunately they can also be quite cumbersome to use, particularly if the functor you would like to apply is unique to the particular function. #include <algorithm>
#include <vector>
namespace
struct f
void operator()(int)
// do something
;
void func(std::vector<int>& v)
f f;
std::for_each(v.begin(), v.end(), f);
If you only use f once and in that specific place it seems overkill to be writing a whole class just to do something trivial and one (...)
#News,Articles&_Books,