Is this code correct?
std::function<int(int)> f = [&f](int n) -> int
{
return n <= 1 ? 1 : n * f(n - 1);
};
int x = f(42);
Is there any potential problem with object construction before it passed as reference to lambda? Or this code absolutely correct?
Capturing f by value leads to crash in msvc2010 compiler.
auto funcnamerather thanstd::function<> funcname.