Google Gruppi non supporta più i nuovi post o le nuove iscrizioni Usenet. I contenuti storici continuano a essere visibili.

C++0x Wish List: Variadic Template Parameters

1 visualizzazione
Passa al primo messaggio da leggere

Davide Bolcioni

da leggere,
10 set 2002, 16:00:3410/09/02
a
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...@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

0 nuovi messaggi