
Doug Gregor wrote:
I have just completed implementing support for "Variadic Templates" in GCC. Variadic templates are C++ templates that can accept any number of "extra" template arguments, just like a function that uses C-style varargs (with "...") can accept any number of extra arguments. Unlike C varags, however, variadic templates work both for class templates and function templates, and are completely type-safe.
A dream come true ... http://groups.google.com/group/comp.std.c++/browse_frm/thread/9432727bc5e67d48/947b100b5ee21f6e?lnk=st&q=&rnum=9&hl=it#947b100b5ee21f6e ... now I'm going to dig up what my need actually was at the time.
Unimpressed? Here's an implementation of tuple that accepts any number of element types:
template<typename... Values> class tuple;
template<> class tuple<> { };
template<typename Head, typename... Tail> class tuple<Head, Tail...> : private tuple<Tail...> {
protected: Head m_head; };
The fact that head() and tail() are not declareda bove is just an omission, is it ?
Are variadic templates worthwhile? Will they help us build better, cleaner Boost libraries in the future? Should we bring variadic templates to the C++ committee, to enable better implementations of TR1 components and eliminate the need for much of the preprocessor metaprogramming we do today? Feedback is greatly appreciated.
Davide Bolcioni -- There is no place like /home.