#include <iostream>
#include <string>
using namespace std;
template<class... InitialArgTypes>
void CallWithExtraParameter(void (*funcPtr)(InitialArgTypes..., int), InitialArgTypes... initialArgs)
{
(*funcPtr)(initialArgs..., 42);
}
void Callee(double a, string b, int c)
{
cout << a << " " << b << " " << c << endl;
}
int main()
{
CallWithExtraParameter<double, string>(Callee, 1.0, string("hello world"));
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGU8Y2xhc3MuLi4gSW5pdGlhbEFyZ1R5cGVzPgp2b2lkIENhbGxXaXRoRXh0cmFQYXJhbWV0ZXIodm9pZCAoKmZ1bmNQdHIpKEluaXRpYWxBcmdUeXBlcy4uLiwgaW50KSwgSW5pdGlhbEFyZ1R5cGVzLi4uIGluaXRpYWxBcmdzKQp7CgkoKmZ1bmNQdHIpKGluaXRpYWxBcmdzLi4uLCA0Mik7Cn0KCnZvaWQgQ2FsbGVlKGRvdWJsZSBhLCBzdHJpbmcgYiwgaW50IGMpCnsKCWNvdXQgPDwgYSA8PCAiICIgPDwgYiA8PCAiICIgPDwgYyA8PCBlbmRsOwp9CgppbnQgbWFpbigpCnsKCUNhbGxXaXRoRXh0cmFQYXJhbWV0ZXI8ZG91YmxlLCBzdHJpbmc+KENhbGxlZSwgMS4wLCBzdHJpbmcoImhlbGxvIHdvcmxkIikpOwp9
prog.cpp: In function 'int main()':
prog.cpp:18:75: error: no matching function for call to 'CallWithExtraParameter(void (&)(double, std::string, int), double, std::string)'
CallWithExtraParameter<double, string>(Callee, 1.0, string("hello world"));
^
prog.cpp:6:6: note: candidate: template<class ... InitialArgTypes> void CallWithExtraParameter(void (*)(InitialArgTypes ..., int), InitialArgTypes ...)
void CallWithExtraParameter(void (*funcPtr)(InitialArgTypes..., int), InitialArgTypes... initialArgs)
^
prog.cpp:6:6: note: template argument deduction/substitution failed:
prog.cpp:18:75: note: mismatched types 'int' and 'double'
CallWithExtraParameter<double, string>(Callee, 1.0, string("hello world"));
^