2
Why write a function object somewhere else?
• class IsEqualToInt {
  int val;
public:
  IsEqualToInt( int v ) : val(v) { }
  template<typename T> bool operator()( T t ) { return t == val; }
};
• find_if( v.begin(), v.end(), IsEqualToInt(3) ); // code lives elsewhere
• find_if( v.begin(), v.end(), { return _x == 3; } ); // lambda function
• find_if( v.begin(), v.end(), _x == 3 ); // lambda expression
Commonality:
•Boost.Lambda exists today; language support is a frequently requested extension for ISO C++0x. No serious proposal yet, but together concepts + lambdas take STL to next level.
•Directly leveraged in Concur and Linq. Concur allows lambda function objects to be active, which is a natural abstraction to spin off arbitrary asynchronous work. Linq programmers can easily pass around predicates and other code.
Lambda Functions