I'd like to be able to do something like this:
Given a function:
void some_func(int a, int b, int c) {
cout << a << b << c;
}
void generic_call(vector<int>& v) {
Args... args(<make_parameter_pack_from>(v));
some_func(args...);
}
make_parameter_pack_from()
takes a vector of arguments and somehow creates a "parameter pack" from it which can then be expanded to its parameters when calling the some_func()
.
The reason I need to do this is that I'm given the arguments in a vector and somehow I need to call a normal C++ function which takes these arguments.
I can use something like libffi to construct the function call but I was really hoping for some C++ variadic template magic which can make this happen.