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
void invoke(std::function f, Ts ... args) {}
void foo(std::string s, int i) {}
invoke(foo, "a", 1); // fail
// mismatched types 'std::function' and 'void
(*)(std::__cxx11::string, int) {aka void (*)(std::__cxx11::basic_string,
int)}'
full code :
#include
#include
template
struct Invoker {
void invoke(std::function f, Ts ... args) {
f(args ...);
}
};
template
void invoke(std::function f, Ts ... args) {
f(args ...);
}
void foo(std::string s, int i) {
std::cout << "foo " << s << " " << i << std::endl;
}
int main() {
Invoker invoker;
invoker.invoke(foo, "a", 1); // ok
invoke(foo, "a", 1); // fail
return 0;
}
main.cc:24:41: note: mismatched types 'std::function' and 'void
(*)(std::__cxx11::string, int) {aka void (*)(std::__cxx11::basic_string,
int)}'
gcc version 5.3.1 20160301 [gcc-5-branch revision 233849] (SUSE Linux)