Joel de Guzman <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Brian McNamara <[EMAIL PROTECTED]> wrote: > > > Offhand, the "pointer interface" for reading the value of an optional > > seems good to me. Being able to say > > > > optional<int> x; > > ... > > if( x ) foo( *x ); > > > > seems like a natural way to "sugarize" this in C++. > > IMO, this is better: > > optional<int> x; > if (x == none) > foo(x); > > Although I don't see this as problematic: > > optional<int> x; > if (x) > foo(x); > > Or perhaps: > > optional<int> x; > if (!!x) > foo(x); > > I see the implicit value access (in foo(x)) as problematic for the reasons I gave before.
> 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; > Yes, I think this should be kept. There is a special section on the documention dealing with the specific case of optional<bool> just in order to support these _very_ idiomatic operations. > 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! > The * syntax is not supposed to make optional<> pretend it is a pointer. It is clearly not and the documentation says so quite clearly, I think. And if it doesn't, then it is the documentation that needs to be fixed. Fernando Cacciola _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost