Topic: C++0x Wish List: Variadic Template Parameters
Author: 6805b3x001@sneakemail.com (Davide Bolcioni)
Date: Tue, 10 Sep 2002 20:00:34 +0000 (UTC) Raw View
Greetings,
I would like to see templates able to take an open-ended set of
arguments, e.g. for a typesafe printf. Something with a syntax like:
// This is the tail case, I could not come up with a
// decent syntax to stop at 0.
template < template <typename Last> ... >
void print(const Last& arg)
{
// In this body, Last is an ordinary typename.
}
// This is the general case.
template < template <typename Head, template Tail> ... >
void print(const Head& head, ...)
{
// In the body, Head is an ordinary typename.
// In the body, Tail is a template not a typename.
sometype x;
print_helper(head);
log(head, x, Tail); // Another variadic function.
print(Tail);
}
print(x, y, z);
On first thought, I would say this should be detailed so that
it is possible to deduce constant expressions as non-type
parameters.
Applying the same syntax to class templates should make the
various typelist efforts much easier and less reliant on the
preprocessor, it seems to me.
Davide Bolcioni
--
Linux - the choice of a GNU generation.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]