Template argument deduction for an argument of a function type
It would seem to me that gcc and clang are correct. This should not compile. The function parameter from which you'd like T
to be deduced becomes a non-deduced context here the moment the argument supplied is an overload set that contains a function template [temp.deduct.type]/5.5:
The non-deduced contexts are:
- […]
A function parameter for which argument deduction cannot be done because the associated function argument is a function, or a set of overloaded functions ([over.over]), and one or more of the following apply:
- […]
- the set of functions supplied as an argument contains one or more function templates.
- […]
Thus, T
cannot be deduced and the other overload is not viable due to there being no conversion; exactly what gcc says…