|
Boost : |
From: Hamish Mackenzie (hamish_at_[hidden])
Date: 2005-10-18 18:47:43
On Tue, 2005-10-18 at 15:03 -0300, Fernando Cacciola wrote:
> > I still can't think of an
> > example where it is desirable to have X * and optional< Y > use the
> > same interface.
>
> Dave's just gave one.
Indeed and I am convinced. Please read my response to that message
though as I had some other questions.
> Something like that is already supported (opt != none)
> It's just not the only way to test for absence.
> In any event, if dropping safe_bool() were a good idea (I'm unsure the bool
> case worth dropping it), that could be left as the only choice.
(opt != none) is cool. Does it work for other OptionalPointees too? If
not, could it?
If the the others stay, the documentation should at least be revised
indicate that the problem is not limited to optional< bool >. Even
changing from "std::istream &" to "optional< std::istream > &" could
easily lead to confusion (boost::tribool won't help much there).
For the record I would be against including (opt != 0) for the same
reason I don't like the "safe_bool" and "operator !". In fact I don't
much care for them existing for any pointers. Using (p != none) or
(p != PointersType()) is much more explicit. I think that the likely
uses of optional make it more vulnerable than pointers.
Thank you for taking the time to address my concerns.
Hamish
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk