Joel de Guzman wrote:
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;

IMHO, there is something terribly wrong here because now optional<T> has two interfaces. The interface of optional itself and the interface of T. If you think that optional<T> can be used like T (having the value-interface), you are immediately fooled by if(x) as it doesn't check T's value. A pointer-interface is much cleaner as it gives the user a hint that he is using a wrapper and in practice, I always prefer to be a little more explicit on these things (even at the cost of an occasional * here and there) than to have silent bugs.


Regards, Daniel

--
Daniel Frey

aixigo AG - financial training, research and technology
Schlo�-Rahe-Stra�e 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: [EMAIL PROTECTED], web: http://www.aixigo.de


_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to