|
Boost : |
From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-12-18 07:13:17
Peter Dimov wrote:
> struct nil;
> struct missing;
> template<class, class> struct pair;
>
> template<class A1 = missing, class A2 = missing, class A3 =
> missing, class A4 = missing> struct list
> {
> typedef typename list<A2, A3, A4, missing>::type rest;
> typedef pair<A1, rest> type;
> };
>
> template<> struct list<missing, missing, missing, missing>
> {
> typedef nil type;
> };
That's clever!
> The number of arguments can be increased arbitrarily,
> although IMO both 50 and 128 are overkill.
MPL offers 15 by default. 128 is the top limit dictated by the current
PREPROCESSOR library implementation (if needed, it can be increased as
well).
> I believe that this implementation compares well with the
> existing solutions offered by Loki and MPL.
It's definitely innovative, and tinyness is always a plus :). Type generator
interface (type_list<>::type) is not ideal, though, considering that other
compile-time sequence - namely 'type_vector' and 'value_range', don't
need/have it.
It would be nice to have a way to get rid of all these 'missing' types in
the list "signature" too ;).
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk