|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-08-31 04:06:12
Joel de Guzman <djowel_at_[hidden]> wrote:
> IMO, this is better:
>
> optional<int> x;
> if (x == none)
> foo(x);
I meant:
optional<int> x;
if (x != none)
foo(x);
Of course. And following Brian's example:
if (o != none)
do_something(o);
else
maybe_do_other();
> Although I don't see this as problematic:
>
> optional<int> x;
> if (x)
> foo(x);
>
> Or perhaps:
>
> optional<int> x;
> if (!!x)
> foo(x);
>
> We already have an implicit conversion to safe_bool and an
> operator ! anyway. Keep it. There's nothing wrong with it:
>
> operator unspecified-bool-type() const;
> bool operator!() const;
>
> Perhaps it's just me, but I really dislike the * syntax. Why make optional
> pretend that it is a pointer when it's clearly not! Then, we go on and give
> it value semantics! C'mon!
-- 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