so I have a template function:
int someFunc(int num) {
int a = num / 2;
int b = num + 10;
return a + num / b + b;
}
template<typename Type, typename Function>
Type test() {
Function func = (Function)&someFunc;
return func();
}
In the function test
I now want to call other different functions, not only someFunc
, which have different parameters. Like this:
template<typename Type, typename Function>
Type test(args) {
Function func = (Function)&someFunc; //This is later replaced with an variable, that contains a address to a different function
return func(args);
}
args
should be like a list of arguments, all of which can be different types. This list I want to pass to the func
. That’s what it would look like:
typedef int(__cdecl* tSomeFunc)(int, int, BYTE*);
int i = test<int, tSomeFunc>(4, 6, "Hey");
template<typename Type, typename Function>
Type test(argument list that accepts all the arguments given above) {
Function func = (Function)&someFunc;
return func(argument list);
}
Is that possible? If not, is there any other way?