#include <utility>
struct example
{
void f0(int, int)
{
}
template<class T>
void f1(T&&, int)
{
}
};
#define FWD(xs) ::std::forward<decltype(xs)>(xs)
template<class T, class... Ts, class... TArgs>
void forwarder(void(T::*fptr)(Ts...), TArgs&&... xs)
{
T instance;
(instance.*fptr)(FWD(xs)..., 0);
}
int main()
{
forwarder(&example::f0, 10);
forwarder(&example::f1, 10);
return 0;
}
I2luY2x1ZGUgPHV0aWxpdHk+CgpzdHJ1Y3QgZXhhbXBsZQp7Cgl2b2lkIGYwKGludCwgaW50KQoJewoJCQoJfQoJCgl0ZW1wbGF0ZTxjbGFzcyBUPgoJdm9pZCBmMShUJiYsIGludCkKCXsKCQkKCX0KfTsKCiNkZWZpbmUgRldEKHhzKSA6OnN0ZDo6Zm9yd2FyZDxkZWNsdHlwZSh4cyk+KHhzKQoKdGVtcGxhdGU8Y2xhc3MgVCwgY2xhc3MuLi4gVHMsIGNsYXNzLi4uIFRBcmdzPgp2b2lkIGZvcndhcmRlcih2b2lkKFQ6OipmcHRyKShUcy4uLiksIFRBcmdzJiYuLi4geHMpCnsKCVQgaW5zdGFuY2U7CgkoaW5zdGFuY2UuKmZwdHIpKEZXRCh4cykuLi4sIDApOwp9CgppbnQgbWFpbigpIAp7Cglmb3J3YXJkZXIoJmV4YW1wbGU6OmYwLCAxMCk7Cglmb3J3YXJkZXIoJmV4YW1wbGU6OmYxLCAxMCk7CglyZXR1cm4gMDsKfQ==
prog.cpp: In function 'int main()':
prog.cpp:30:28: error: no matching function for call to 'forwarder(<unresolved overloaded function type>, int)'
forwarder(&example::f1, 10);
^
prog.cpp:20:6: note: candidate: template<class T, class ... Ts, class ... TArgs> void forwarder(void (T::*)(Ts ...), TArgs&& ...)
void forwarder(void(T::*fptr)(Ts...), TArgs&&... xs)
^
prog.cpp:20:6: note: template argument deduction/substitution failed:
prog.cpp:30:28: note: couldn't deduce template parameter 'T'
forwarder(&example::f1, 10);
^