Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2002-11-05 17:21:12

----- Original Message -----
From: "Arkadiy Vertleyb" <vertleyb_at_[hidden]>

> Your approach uses different, but related, classes for tuple to derive from
> (c1) and for the field access (field<c1>).
> On the other hand, I once suggested (to be more accurate this is not exactly
> my idea -- I borrowed it from somewhere) to pass c1& instead of c1*, so that
> the call looks like:
> tuple[c1()] = 5;
> employee[last_name()] = "Smith";
> The above looks pretty nice, except now we should pay the penalty for the
> creation of the temporary object. It's not clear whether compilers would
> optimize this away.

Oh I'm pretty sure the compiler will optimize away the temporary.
However, if you want to be sure, there's only one way to find out :-)

> I think we could combine the above two approaches to achieve the desired
> result. If we get the data from the "column" class into the nested class,
> say field, we should get what we need:
> template <class Type> struct column {
> typedef Type type;
> class field {
> type value_;
> };
> };
> Then tuple<list<c1> > is derived from c1::field, and when tuple[c1()] is
> called, it's static_casted to c1::field too. The syntax is pretty nice, and
> the penalty for the creation of c1 are minimal.

Nice! Now, there's one more macro to remove :-)


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