I'm trying to forward tuple arguments to a function in VS2012 (update 3).
My understanding is that this is possible in C++11 using variadic templates, unfortunately, VS2012 only supports "fake" variadics.
auto Values = std::make_tuple(4, 8);
auto Add = [](int a, int b) -> int { return a + b; };
auto Result = forward_to_function(Add, Values);
I'm hoping that there is a way in VS2012 to implement the functionality shown above, but I'm not sure, is this possible without true variadics?
I saw mention of just such an "exploder" in a Channel 9 video. I think it was the most recent "Going Native" Someone (Andrei?) was reported as having a full general solution, but it was not presented. There were less complete workable solutions talked about.
If you can wait, the current VS preview compiler has true variadics.
Look how Boost does it: implement a whole bunch of args, with a special flag type as a default argument that indicates it is missing.
Normally, for a function (not a class) I would overload it. Overloading templated functions is just fine, too: the arguments to forward_to_function must be expanded out so it can match each parameter type, so you were doing that anyway. Only instead of "..." you write some fixed number of params. Overload it with another definition that has a different number, for as many as are actually needed by the program.
—John