|
Boost : |
From: Davide Bolcioni (davide_bolcioni_at_[hidden])
Date: 2006-08-05 04:40:03
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 ...
... 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk