[Bug c++/70810] New: std::function template variadic template arguments do not unpack in function template

2016-04-26 Thread sd.foolegg at gmail dot com
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)

[Bug c++/70810] std::function template variadic template arguments do not unpack in function template

2016-05-04 Thread sd.foolegg at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70810

sd.foolegg at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #3 from sd.foolegg at gmail dot com ---
(In reply to Jonathan Wakely from comment #1)
> Not a bug, the parameter pack for std::function cannot be
> deduced from the arguments, because a function pointer is not a
> std::function.

why below code can run?:

template
struct Invoker {
void invoke(std::function f, Ts ... args) {
f(args ...);
}
};

Invoker invoker;
invoker.invoke(foo, "a", 1); // ok

and visual studio 2015 can deduce parameter pack normally (same code).