I'm playing around with variadic function templates in C++11 and have got the basic idea with code something like:
void helper() { std::cout << "No args" << std::endl; } template< typename T > void helper( T&& arg ) { size_t n = 0; std::cout << "arg " << n << " = " << arg << std::endl; helper(); } template< typename T, typename... Arguments > void helper( T&& arg, Arguments&& ... args ) { size_t n = sizeof...( args ); std::cout << "arg " << n << " = " << arg << std::endl; helper( args... ); } However, what I want is for the argument number (the variable n in the code) to count up rather than down. How can I do this elegantly? I could write a wrapper function that creates a 'hidden' argument count but I feel there should be a neater way?
Thanks!