Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Lambda functions are one of the most exciting features of the C++11 Standard, because they have the potential to greatly simplify code and eliminate much of the boilerplate associated with writing callable objects. The C++11 lambda function syntax allows a function to be defined at the point where it’s needed in another expression. This works well for things like predicates provided to the wait functions of std::condition_variable (as in the example in section 4.1.1), because it allows the semantics to be quickly expressed in terms of the accessible variables rather than capturing the necessary state in the member variables of a class with a function call operator.
At its simplest, a lambda expression defines a self-contained function that takes no parameters and relies only on global variables and functions. It doesn’t even have to return a value. Such a lambda expression is a series of statements enclosed in braces, prefixed with square brackets (the lambda introducer):