I want to call a function taking 2 parameters but I want to call this function without actually writing f(arg1, arg2)
. For example I have a function:
float f(float a, float b) {
// ...
}
And I want to call it with but from a vector:
std::vector args = {1.f, 1.f}; // arguments stored in vector
f(args[0], args[1]); // call the function
In this example it works but in fact I don't know how many args there are so I want to do something like:
std::vector args = {...};
f(args...); // pass all elements as arguments