http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45873
Summary: Parameter packs not expanding consistently in function return types Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: saus...@tehsausage.com Non-variadic templates passed to a function as "template <class ...> class" have inconsistent behavior when provided with a parameter pack as an argument and used as a return type than when used in the body of the function in the same way. I am unsure on the expected behavior or whether passing templates in such a way is even allowed. 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...); } int main() { foo<pair>(1, 2.0); // error: no matching function for call to 'foo(int, double)' bar<pair>(1, 2.0); // OK, returns pair<int, double> } 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() { baz(1, 2.0); // OK, returns pair<int, double> }