I wrote a convenience function that gets some arguments and then sends them to the right functions:
void combine(int a, int b, double one, double two) {
funA(a,b);
funB(one, two);
}
Now I want to do it again, but with variadic template parameters for both my combine
function and the funA
-funB
pair:
//somewhere earlier in the code
template<class U, class T> funA(U par1, T par2) {...}
template<class X, class Y> funB(X par1, Y par2) {...}
template<class ...ParamA, class ...ParamB>
void combine(ParamA...packA, ParamB...packB) {
funA(packA...);
funB(packB...);
}
This of course can't work because I need some way to divide the parameters list in half.
But what is more interesting is when I try to compile the above code with a call like
combine(10, 'a', 12.0, true)
I get this error:
In instantiation of ‘void combine(ParamA ..., ParamB ...) [with ParamA = {}; ParamB = {int, char, double, bool}]’:
...
error: no matching function for call to ‘funA()’
....
error: no matching function for call to ‘funB(int&, char&, double&, bool&)’
which shows that ParamB
"ate" all of the parameter list.
So, my question is: is there a way to divide the parameter list of a function with variable template list in half?. If not, how else may I write my combine
function?