From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-02-22 16:58:52
Oops, I should say something what the lambda library is for:
The (Boost) Lambda Library (BLL in the sequel) implements form of
lambda abstractions for C++. The term originates
from functional programming and lambda calculus, where a lambda
abstraction defines an unnamed function.
The primary motivation for the BLL is to provide flexible and convenient
means to define unnamed function objects for STL algorithms.
In explaining what the library is about, a line of code says more than a
thousand words; the following line outputs the
elements of some STL container x separated by spaces:
for_each(x.begin(), x.end(), std::cout << _1 << ' ');
std::cout << _1 << ' '
defines a unary function object. The variable _1 is the parameter of
this function, a placeholder for the actual argument. Within
each iteration of for_each, the function is called with an element of x as
the actual argument. This actual argument is substituted for the
placeholder, and the `body' of the function is evaluated.
The essence of BLL is letting you define small unnamed function objects,
such as the one above, directly on the call site of an STL algorithm.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk