Boost logo

Boost :

From: Sofus Mortensen (list_at_[hidden])
Date: 2001-12-17 08:23:11


This solution is very, very close to what I used for Comet:

    template<COMET_LIST_TEMPLATE> struct make_list
    {
        typedef tl_t<X00, typename make_list<COMET_LIST_ARG_0>::result>
result;
    };

    template<> struct make_list<COMET_LIST_NIL>
    {
        typedef nil result;
    };

With:

#define COMET_LIST_TEMPLATE typename X00=nil, typename X01=nil, typename
X02=nil, ...
#define COMET_LIST_TEMPLATE_ typename X01=nil, typename
X02=nil, ...

#define COMET_LIST_NIL nil, nil, nil, nil, ...
#define COMET_LIST_ARG_1 X00, X01, X02, X03, X04, ...
#define COMET_LIST_ARG_0 X01, X02, X03, X04, ...

This way I can easily define a template class with psuedo-variable
number of arguments like:

template<COMET_LIST_TEMPLATE>
class Foo
{
        typedef make_list<COMET_LIST_ARG_1>::result tl;

        // work on tl.
};

Best regards,

Sofus Mortensen

Comet - Grunge free COM programming in C++
http://www.lambdasoft.dk/comet

> -----Original Message-----
> From: Peter Dimov [mailto:pdimov_at_[hidden]]
> Sent: Monday, December 17, 2001 2:09 PM
> To: Boost List
> Subject: [boost] (list a1 a2 ... aN) proposed implementation
>
>
> 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;
> };
>
> The number of arguments can be increased arbitrarily,
> although IMO both 50 and 128 are overkill.
>
> I believe that this implementation compares well with the
> existing solutions offered by Loki and MPL.
>
> --
> Peter Dimov
> Multi Media Ltd.
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-unsubscribe_at_[hidden]>

Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk