The lambda doesn't have type std::function<bool(char)>
, it is just some callable object with implementation defined type.
It can be converted to std::function<bool(char)>
, but that doesn't help the compiler to deduce the type for the template case. There could for example be lot's of possibilities for CharType
for which the lambda can be converted to std::function<bool(CharType)>
.
The compiler tries to match the type of the lambda against the parameter of the template function. The lambda has for example a type like lambda_t_1234
and the template parameter is std::function<bool(CharType)>
. The types are unrelated and it's not clear what CharType
is supposed to be here.
This also isn't special to lambdas or std::function<>
. The same happens in all such cases:
template<typename Char>
void f(const std::basic_string<Char> &str) {
}
If you try to call this template function with a char*
parameter it won't work, because the connection to the template parameter isn't clear.