http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45873
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |4.4.3, 4.5.1, 4.6.0 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-04 08:11:07 UTC --- (You didn't say which version this PR is for, although it doesn't work with any I tried) Here's a self-contained testcase, with a fix so the workaround actually works (it was missing the template argument on baz<pair>) template<class, class> struct pair { template<class T1, class U1> pair(T1&& t, U1&& u) { } }; template <template <class ...> class T, class ...Args> auto foo(Args... args) -> T<Args...> { return T<Args...>(args...); } template <template <class ...> class T, class ...Args> auto bar(Args... args) -> T<int, double> { return T<Args...>(args...); } // The following work-around seems to work: template <template <class ...> class T, class ...Args> struct expand { typedef T<Args...> type; }; template <template <class ...> class T, class ...Args> auto baz(Args... args) -> typename expand<T, Args...>::type { return T<Args...>(args...); } int main() { // error: no matching function for call to 'foo(int, double)' foo<pair>(1, 2.0); bar<pair>(1, 2.0); // OK, returns pair<int, double> baz<pair>(1, 2.0); // OK, returns pair<int, double> } I think deduction fails for foo<pair>(1, 2.0), though I'm not sure if it should. For baz<pair> deduction succeeds, the template parameters appear in a nested-name-specifier which is a non-deduced context.