Say I have a variadic function, foo
:
template <typename... Args>
void foo(Args... args)
{
// some work
}
I want to have a magic function, bar
, that forwards its arguments to foo
in the following manner:
Say if I call
bar(x, y, z);
It'll have the same effect as
foo(x.begin(), x.end(), y.begin(), y.end(), z.begin(), z.end());
How to implement such bar()
?
template <typename... Args>
void bar(Args... args)
{
// what should I put here?
// foo( (args.begin(), args.end()) ... ); // doesn't work
}