From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2002-12-10 13:27:22
----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Tuesday, December 10, 2002 9:23 AM
Subject: Re: [boost] Formal review: Optional library
> From: "Fernando Cacciola" <fernando_cacciola_at_[hidden]>
> > The conversion to bool for a smart pointer unambiguously refers to the
> > NULL state of the pointer wrapped.
> > In the case of optional, a conversion to bool will be ambiguous in those
> > cases were the wrapped T in optional<> is bool itself.
> On the other hand, it would enable the useful idiom
> if(optional<T> pt = get_optional_T())
> // use *pt
Yes, it would.
> I don't think that optional<bool> is an important use case (outside of
> generic contexts) since optional<bool> is simply a tri-state type with an
> inconvenient interface.
Good point. I've been using optional<bool> long before tribool existed.
Now I might replace optional<bool> with tribool; but, a user still
can have optional<bool>.
I wouldn't specialize optional<bool> for reasons I gave before.
Though I see that you've found a really useful idiom, I still not sure it
the potential danger. (see my response to William)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk