Road to C++0x : Variadic Templates
The C++ Standards Committee has worked on many new features that will be added to C++. Since the new version of C++ is not ready for the moment, everybody use the ‘C++0x’ name, hoping that the ‘x’ will become ‘9′, that’s to say the standard draft of C++0x will be the new official one during 2009.
Douglas Gregor and Bjarne Stroustrup have in particular worked on a templates-related feature : Variadic Templates.

To introduce it, we’ll first have to remember a particular C syntax…
1 | void printf(char* s, ...); |
Indeed, it’s about the “…” syntax. This is a variadic function, in C.
In C++0x, thank to our two cplusplusies, we’ll be able to do that.
1 2 3 4 5 6 7 | template <typename T, typename... Args> struct count { static const int value = 1 + count<Args...>::value; }; const int args_size = count<int, char, bool, std::string>::value; // args_size == 4 |
In other words, it means we’ll be able to wait an arbitrary number of template paramters for a variadic template class or function. They can also be constant expressions like ints, …
Some applications of that feature will be an easy way to write tuple classes, to initialize standard containers with an arbitrary number of values, to bind functions with an arbitrary number of fixed arguments, etc.
I’ll probably write an article on Developpez.com about that new feature.
However, you can begin with reading Douglas Gregor’s page about variadic templates and particularly its documentation section.



Alléchant tout ça, vivement la norme C++0x :p
hello…
exellent…