I was practicing with lambdas and I found the following code:
auto make_fibo()
{
return [](int n) {
std::function<int(int)> recurse;
recurse = [&](int n){
return (n<=2)? 1 : recurse(n-1) + recurse(n-2);
};
return recurse(n);
};
}
I did not know it was function
or how I worked after searching and reading several texts, for example the following:
My question is yes, std::function
is similar to the following, for example:
typedef int (*FredMemFn)(int i);