I have a template function that I need to call, it looks something like this:
template<typename R, typename... A>
R fn_call(qword fn, A... args) {
using T = R(*)(A...);
fn = ...
return ((T)fn)(args...);
}
#define wrapper_call(FUNC, ...) (fn_call<return_type_t<decltype(FUNC)>>((qword)FUNC, __VA_ARGS__))
Getting the return type for the function is simple, but I also need each argument. If I use it in its current state, the following will have issues because the stack parameters are not correct after r8.
void func(int a1, int a2, int a3, int a4, qword a5)
wrapper_call(func,0,0,0,0,0)
the 5th argument will be passed as a 4 byte int, when it must be a qword.
I am using C++17, and no standard library
question from:
https://stackoverflow.com/questions/65879377/c17-find-exact-arguments-of-function-and-pass-to-template-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…