Lambda Functions
Lambdas functions C++11 provides the ability to create anonymous functions, called lambda functions. It allows a function to be defined at the point where it’s needed in another expression. It is a function that we can write inline in our code to pass in to another function. We can use lambdas wherever a function object or a functor is expected. lambdas are more convenient than function objects because the tedium of writing boilerplate code for every function class (a constructor, data members and an overloaded operator() among the rest) is relegated to compiler. A lambda expression has the form : [capture] (parameters)->return-type {body} The [] construct inside a function call’s argument list indicates the beginning of a lambda expression. Capture Lists. Unlike an ordinary function which can only access its parameters and local variables, a lambda function can also access variables from the enclosing scope. There are two ways to capture variables with