Lambda expressions are coming to C++. In the next version of C++ standard, C++0x, lambda expressions will be included.

In C++0x a lambda expressions is in the form of […](…}{…} where

1. […] indicates it is a lambda expression
2. (…) declares the parameters
3. {…} defines the expressions ie. the code of the lambda expression

// vector to store some integer values
std::vector<int> v;

// Add some values

// print the values
std::for_each(v.begin(); v.end(), [&]( const int& n ) { cout << n << " "; }); int nTotal = 0; // find the total std::for_each(v.begin(); v.end(); [&total](int n){ total+=n; });

This document describes the lambda expression proposal. For a detailed explanation visit Herb Sutter's post.