H
Haochen Xie
.... I'm trying to declare a lambda function returning a lambda function, and, unfortunately, I could not use auto key word since it would be the return type of my function. The lambda function looks like this:
typedef std::function<void(string)> Func;
vector<pair> set;
auto lambda = [&set] (string cmd, Func func) {
set.push_back(pair(cmd, func));
return lambda;
};
return lambda;
I try to use std::function template to express that, but.. As you see, an infinite recursion occurs...
So how could I do that? Any one have any idea?
BTW, the above code compiles without the last returning line. So I CAN have a lambda function like that.
typedef std::function<void(string)> Func;
vector<pair> set;
auto lambda = [&set] (string cmd, Func func) {
set.push_back(pair(cmd, func));
return lambda;
};
return lambda;
I try to use std::function template to express that, but.. As you see, an infinite recursion occurs...
So how could I do that? Any one have any idea?
BTW, the above code compiles without the last returning line. So I CAN have a lambda function like that.