Lambda expressions

Introduced in C++11, lambda expressions allow you to write anonymous functions on the fly. They're particularly useful for short snippets of code that are passed to algorithms or thread functions.


  auto lambda = [](int x, int y) -> int { return x + y; };
  

Beginner's Guide to C++