3

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.

shoosh
  • 76,898
  • 55
  • 205
  • 325
  • There was a similar question to this a couple of days ago, but it was a `std::tuple` instead of a `std::vector`. Edit: [Found it](http://stackoverflow.com/q/27798098/150634). – Joseph Mansfield Jan 07 '15 at 14:51
  • And if all else fails, would `some_func(v[0], v[1], v[2])` be much of a problem? – Joseph Mansfield Jan 07 '15 at 14:53
  • Won't work with a vector. Template magic is all resolved at compile time, when you don't yet know the size of the vector. You could do it with an array, though. – Wintermute Jan 07 '15 at 14:54

0 Answers0