Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-08-29 23:18:59


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.

> 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.

Many thanks!

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk