http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46719
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-01 01:51:06 UTC --- (In reply to comment #6) > I think I did a bad job describing the issue, and I think that it's still a > problem. I'd like to clarify it if I can. The following code works: > > template <typename Return, typename... Args> > int curry(function<Return(double)> func) // NOTE: double Here, Args can never be deduced, so must be given explicitly. > { > return 0; > } > > int f(double x) > { > return 0; > } > > int main() > { > curry<int, double>(f); Args... must be {double} It is not possible to call curry() without giving all template args, so the compiler knows that the only viable specialisation is where Args...=double > } > > While this does not: > > template <typename Return, typename... Args> > int curry(function<Return(Args...)> func) // NOTE: Args... Here Args... appears in a parameter and can be deduced. > { > return 0; > } > > int f(double x) > { > return 0; > } > > int main() > { > curry<int, double>(f); > } > > Even though the template parameter pack Args expands to double, GCC is unable > to match f to the type function<int(double)> if I use Args..., where it was How does it know the template parameter pack expands to double? Maybe it expands to {double,T} and you want T to be deduced. Or maybe {double,T,U} If you passed a function<int(double)> it could deduce Args, but passing f requires a user-defined conversion to an unknown type, so deduction cannot succeed.