|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2005-10-28 03:01:02
On 10/18/05 9:50 AM, "Fernando Cacciola" <fernando_cacciola_at_[hidden]>
wrote:
> Hamish Mackenzie wrote:
[SNIP]
>> Could the unifying concept OptionalPointee be implemented as free
>> functions?
>
> Of course.
>
> Notice that there are alternatives for safe_bool() that doesn't require
> dropping * and ->.
> These alternatives fix the problem with optional<bool>.
> One example is to simply provide operator !, used like this:
>
> if ( !!opt )
> is_initialized();
>
> (this is what my initial boost submission did)
I would find having type with an "operator not" but not any Boolean
conversion to be a surprise. In fact, I filed a bug for Boost.Rational
having this problem. (But I think that case was by accident, not design.)
The double-not operator as a workaround for Boolean conversion is an idiom
that we should NOT be introducing.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk