Posts tagged lambdas

Lambdas in C++11

:: C++11, closures, lambdas

Lambda expressions have been introduced to C++ with the most recent standard, presented in Section [expr.prim.lambda]. They allow the creation of simple functions without giving them a name. What are they good for? Being simple is not really the point here; the most useful case that I have found in my limited experience has been as a convenient replacement for Functors (also known as Function objects).

In this post, I’ll give a quick introduction to how to use lambdas in your code. In the next installment, I will discuss a small example of functor, and will show side by side a piece of code with functors and its substitution with a clean lambda.