Possible Duplicate:
Recursive lambda functions in c++0x
Here is a plain old recursive function:
int fak(int n)
{
return (n <= 1) ? 1 : n * fak(n - 1);
}
How would I write such a recursive function as a lambda function?
[](int n) { return (n <= 1) ? 1 : n * operator()(n - 1); }
// error: operator() not defined
[](int n) { return (n <= 1) ? 1 : n * (*this)(n - 1); }
// error: this wasn't captured for this lambda function
Is there any expression that denotes the current lambda so it can call itself recursively?