std::function allows you to do this:
std::function<void()> = []()->int{return 42;};
But not this:
std::function<void()> = [](int i)->int{return 42;};
Presumably because the return type is not part of the function signature. But std::function is the type of the class that is given the type of the return value and it knows the type of the return object of the function from which it built. So there is a compiler error here.
Why is there no compiler error?
source share