|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2003-08-30 14:49:07
"Joel de Guzman" <djowel_at_[hidden]> escribió en el mensaje news:013d01c36eb0$a1581670$64646464_at_godzilla...
> Eric Friedman <ebf_at_[hidden]> wrote:
> > Joel,
> >
> > Joel de Guzman wrote:
> > [snip]
> >> Also, is there a reason why we can't allow:
> >>
> >> variant<int&, double&> var;
> >
> > Nothing fundamental no, just some additional metaprogramming ;) It's
> > supported now (see variant_reference_test).
>
> Cool!
>
> > See below for a note on the semantics of the resultant variant type, though.
>
> I know what you mean and I agree.
>
> >> IIUC, internally, it's just a matter of storing a boost.reference_wrapper
> >> if T is a reference.
> >
> > Well, IMO reference_wrapper isn't exactly the right solution since it is
> > Assignable whereas references aren't. So I introduced (in the variant detail
> > namespace) reference_content. It stores a reference, but allows placement
> > new to occur in the variant implementation.
> >
> > The ultimate result of all this: variant< int& > is not Assignable, while
> > variant< reference_wrapper<int> > is. I believe this is as it should be, but
> > please disagree if you don't.
>
> Agreed! That is the exact semantics I was hoping for.
>
I do to.
Makes perfect sense to me.
Eric: Is it possible to promote reference_content to boost/detail (instead of boost/variant/detail) so it can be used
by optional<>?
> > Nope, thanks for the idea.
>
> I think the tuple, variant and optional are very important infrastructures
> for the meta-programmer. I believe that the three should have a consistent
> interface and follow some basic underlying concepts, type requirements, etc.
>
I think optional<> benefits of a special interface since it is all about a more convenient way to use variant<T,nil>,
but it defenitely should follow the semantics, type requirements and underlying concepts.
Fernando Cacciola
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk