Boost logo

Boost :

From: Mat Marcus (mmarcus_at_[hidden])
Date: 2001-11-27 19:40:19


Andrei Alexandrescu writes:
>...and that Mat Marcus posted a port of Loki's typelists to MSVC
> to boost already. Thanks Mat!

The aforementioned typelist.hpp MSVC 6 port is available in the files
section. For those who are interested in the details here is an abstract
from the porter's notes:

/*
        A Note on the port: This is a first attempt at porting
        boost/loki typelists to VC6.sp5. There is nothing too fancy
        here, just a relatively mechanical port with the aim of
        remaining faithful to the original coding style.
        I tried several different approaches, but I
        ran into various internal compiler errors along the
        way. Please forgive any remnants of previous attempts that
        still remain in the code - this is a work in progress. In the
        end I chose the following approach to eliminating partial
        specialization dependencies.

        The approach is best illustrated by example. Consider the
        erase metafunction. The basic structure is:

        template <class T> // Specialization 1
        struct erase<null_typelist, T> { ... };

      template <class T, class tail> // Specialization 2
      struct erase<type_list<T, tail>, T>

      template <class head, class tail, class T> // Specialization 3
      struct erase<type_list<head, tail>, T> { ... };

        Here there are three cases: null_typelist, t_is_head, and
        general_typelist. I convert this to use a master erase
        metafunction and three helper metafunctions wrapped up in
        structs to mirror the original partial specializations.:

        enum case_tag {null_typelist_case, t_is_head_case,
        general_typelist_case };

        template <case_tag tag>
        struct erase_specialization;

        template <>
        struct erase_specialization<null_typelist_case>
        { // Specialization 1
                template <class TList, class T>
                struct result {
                        typedef null_typelist type;
                        // original code goes here
                };
        };

        template <> struct erase_specialization<t_is_head_case>
        {
                template <class TList, class T> struct result {
                typedef /*... * / type;
        // original code goes here, etc.
        };

        }; // Specialization 2

        template <> struct
        erase_specialization<general_typelist_case> {...};
        //Specialization 3

        The body of each nested "result" template essentially matches
        the original specializations. Note for example that in the
        general_typelist case we can safely assume that TList is a
        non-null typelist to extract head and tail if necessary.

        With the three specializations in hand (and a couple of
        helpers from detail) we can write the master erase
        metafunction like this:

        template <class TList, class T>
        struct erase{
          typedef typename detail::erase_specialization<
            detail::is_null_typelist<TList>::value ?
              null_typelist_case :
              detail::is_t_head<TList,T>::value ? t_is_head_case :
              general_typelist_case
>::template result<TList, T>::type type;
        };
*/

-----Original Message-----
From: Andrei Alexandrescu [mailto:andrewalex_at_[hidden]]
Sent: Tuesday, November 27, 2001 2:29 PM
To: boost_at_[hidden]
Subject: Re: [boost] Submission: typelist

... and that Mat Marcus posted a
port of Loki's typelists to MSVC to boost already. Thanks Mat! ...


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