C++ Lambda

In C++11 and later, a lambda expression—often called a lambda—is a convenient way of defining an anonymous function object (a closure) right at the location where it’s invoked or passed as an argument to a function.

  • MSDN
  • [capture](parameters) -> return_type { function_body }
  1. capture clause (Also known as the lambda-introducer in the C++ specification.)
  2. parameter list Optional. (Also known as the lambda declarator)
  3. mutable specification Optional.
  4. exception-specification Optional.
  5. trailing-return-type Optional.
  6. lambda body.

Capture clause

[] it means that you will not provide anything to give to lambda.
[&] it is used to say that you have some references to mess with.
[=] it is used to make the copy.
[this] is used to the enclosing class.