1 回答
There are proposals to do something like this in C++1y, whose state I am not current on.
Your syntax is not right for those proposals, as a lambda is the wrong type to instantiate a std::function
template with. It wants a signature, not the type of some lambda.
Writing a make_wrap
is possible, but requires taking the lambda type and extracting the args and return value yourself. It is also rarely a good idea, because if the only way you know a std::function
s type is from deduction, in that context why type erase it? Instead, carry the raw lambda type around.
There are reasons to want to do that, but they are rarely good.