Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-02-19 10:33:37


"Peter Dimov" <pdimov_at_[hidden]> writes:

> David Abrahams wrote:
>> "Peter Dimov" <pdimov_at_[hidden]> writes:
>>
>>> It may be possible to use optional<T&> (is it supported?) or
>>> optional< reference_wrapper<T> > but this looks like an "obfuscated
>>> C++" entry to me compared to T*.
>>
>> Good point.
>>
>>> What's wrong with it? What does optional<T&> add?
>>
>> Suppose you have a
>>
>> variant<mpl::list<int&, std::string&> >
>>
>> How do you check to see if it contains an int&?
>
> You don't. "int&" doesn't meet the variant requirements.

Too bad. Could be very useful, just like a tuple of references is
useful.

> Even if it did:
>
> variant< int, int& > v;
>
> How do you check to see if it contains an int&?

I don't know, maybe:

      optional<exactly<int&> > w = v;

??

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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