|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2002-11-01 21:14:07
----- Original Message -----
From: "Joel de Guzman" <djowel_at_[hidden]>
Subject: Re: [boost] Re: Re: Re: Re: relational table asanSTLcontainer--anyinterest?
> ----- Original Message -----
> From: "Arkadiy Vertleyb" <vertleyb_at_[hidden]>
>
> >
> > There were many times when I PROVED that something can't be done, and then
> > actualy did it... Or somebody else did it. :o))
>
> Surely!
>
> > > Another comment is the tuple. I think boost tuples can be used.
> > >
> >
> > Boost tuples allow the access by the position number. To access by name,
> > we would have to somehow map the name to the position number. We would
> > probably have to use strings to define names, which would elliminate the
> > posibility of compile time checks. Also, static_cast should be
> > significantly faster than iterating through boost::tuple fields.
>
> I do not agree with you. First, the "iteration" is optimized
> by the compiler. Second, which is also related to my previous
> comment on MACROs, I don't see any reason why fields and
> columns can't be refered to by place holders as do boost.bind,
> boost.lambda, boost.tuples and phoenix. Names? Sure you can
> use names. Here's an example using Phoenix:
>
> tuple_index<0> my_field;
> val = tup[my_field];
>
> see http://spirit.sourceforge.net/index.php?doc=docs/phoenix_v1_0/tuples.html
BTW, if you wish to have the tup.field syntax, you might find
inspiration in boost.spirit closures. Example syntax:
struct my_tuple : tuple_fields<my_tuple, std::string, int, int>
{
member1 name;
member2 id;
member3 age;
};
Then:
my_tuple tup;
std::cout << tup.name << std::endl;
see http://spirit.sourceforge.net/index.php?doc=docs/v1_5/closures.html
Regards again,
--Joel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk