Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-04-26 20:26:42

On 04/26/2005 05:22 PM, Giovanni P. Deretta wrote:
> As your code demonstrates, enumerators can be used without duplicating
> information, but an enum and map enum->type is required for each tuple.
> This is verbose and should be wrapped in a macro. Then again, I don't


> like macros a lot :)

But mpl and fusion are profuse with macros, or at least

> In the end, getting 'by type' has the same expressive power of using
> enumerators, i simply think that it would have a better syntax and it
> would work out of the box with all tuples without the need of a map.

But it wouldn't work for repeated types, unless, as you
noted previously, some sort of "tag" were "associated" with
the type, which is what an mpl::map does, only it assures there's
only one type associated with each tag; whereas the example:

   tuple<mpl::list<element1_type, element1_tag>, mpl::list<element2_type,

in one of your previous messages:

doesn't assure this, AFAICT. Also, I'd think mpl::pair would be more
succinct. So, the tuple version of the following:

   struct employ
   { string name;
      float salary;
      int ssn;

could be:

   struct name{};
   struct salary{};
   struct ssn{};

   < mpl::pair<string,name>
   , mpl::pair<float,salary>
   , mpl::pair<int,ssn>

which is not that much shorter than the enum_map_0 shown in my
previous post:

After all, for each enum_map_0::f_i, for i=0..2, there's
got to be a tag with your method:

   struct name{};
   struct salary{};
   struct ssn{};

and there's also got to be a pairing of tags to types, just as in
the enum_map_0::field_map.

Am I missing something?

Boost list run by bdawes at, gregod at, cpdaniel at, john at