Using std::function with templates

The parameter func is declared as std::function, and you're trying to pass a function pointer, which requires implicit conversion. Template argument deduction doesn't consider implicit conversion and then deduction fails.

Type deduction does not consider implicit conversions (other than type adjustments listed above): that's the job for overload resolution, which happens later.

You can construct an std::function explicitly,

f('a', 'b', static_cast<std::function<bool(const char&, const char&)>>(g<char>));

Or specify the template argument explicitly (to bypass template argument deduction and make implicit conversion taking effect later),

f<char>('a', 'b', g<char>);    

Or just don't use std::function.

template <class T, class F>
bool f(const T &a, const T &b, F func)
{
    return func(a,b);
}

f('a', 'b', g<char>);