How does template argument deduction work when an overloaded function is involved as an argument?
问题 This is the more sophisticated question mentioned in How does overload resolution work when an argument is an overloaded function? Below code compiles without any problem: void foo() {} void foo(int) {} void foo(double) {} void foo(int, double) {} // Uncommenting below line break compilation //template<class T> void foo(T) {} template<class X, class Y> void bar(void (*f)(X, Y)) { f(X(), Y()); } int main() { bar(foo); } It doesn't appear a challenging task for template argument deduction -