1
4

1 回答 1

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::functions 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.

于 2013-10-02T10:37:09.843 回答