|
Boost : |
From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2002-11-05 05:22:11
"Joel de Guzman" <djowel_at_[hidden]> wrote in message
news:00cf01c2844c$31a12320$4f4ca7cb_at_kim...
>
> ----- Original Message -----
> From: "Arkadiy Vertleyb" <vertleyb_at_[hidden]>
>
>
> > Can't we achieve the same result with:
> >
> > c1* field_c1 = 0;
> > tuple[field_c1] = 5;
> >
> > ?
> >
> > Arkadiy
>
> Yes, but I thought you didn't like the NULL pointer?
> I also find the null not likeable.
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.
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.
> --Joel
>
> PS> In convert.cpp you have
> #include "convertion.h" and convertion<...> instantiations.
> Wouldn't that be "conversion" instead?
Whoops...
convert.cpp is an obsolete file -- we just forgot to remove it.
conversion.cpp is the correct one.
Arkadiy
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk