https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70810
Bug ID: 70810 Summary: std::function template variadic template arguments do not unpack in function template Product: gcc Version: 5.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sd.foolegg at gmail dot com Target Milestone: --- std::function template variadic template arguments do not unpack in function template, like this: template<typename ... Ts> void invoke(std::function<void(Ts ...)> f, Ts ... args) {} void foo(std::string s, int i) {} invoke<std::string, int>(foo, "a", 1); // fail // mismatched types 'std::function<void(Ts ...)>' and 'void (*)(std::__cxx11::string, int) {aka void (*)(std::__cxx11::basic_string<char>, int)}' full code : #include <iostream> #include <functional> template<typename ... Ts> struct Invoker { void invoke(std::function<void(Ts ...)> f, Ts ... args) { f(args ...); } }; template<typename ... Ts> void invoke(std::function<void(Ts ...)> f, Ts ... args) { f(args ...); } void foo(std::string s, int i) { std::cout << "foo " << s << " " << i << std::endl; } int main() { Invoker<std::string, int> invoker; invoker.invoke(foo, "a", 1); // ok invoke<std::string, int>(foo, "a", 1); // fail return 0; } main.cc:24:41: note: mismatched types 'std::function<void(Ts ...)>' and 'void (*)(std::__cxx11::string, int) {aka void (*)(std::__cxx11::basic_string<char>, int)}' gcc version 5.3.1 20160301 [gcc-5-branch revision 233849] (SUSE Linux)