
Fernando Cacciola wrote:
Joel de Guzman wrote:
(i.e. no assigment from T and the reset(), reset(nil), reset(T) syntax).
Well, I'm not so sure about reset(). My very first boost submision had reset() and no assignment from T, exactly as we are considering now. But the big problem, and it was big, was that it just made people be even more confused about optional<> being yet another smart pointer (precisey becasue auto_ptr and shared_ptr uses it).
AFAICT, the choice between:
o = make_optional(val); o = nullptr ;
and
o.reset(val); o.reset();
is just cosmetical.. and at that, I prefer the first version because it pushes optional<> away from a smart_ptr.
IOW, that it uses * and -> just like any other nullable type makes sense because the semantics of these operators are the same for all nullable types; but the semantics of reset() in the case of optional<> are different from those of a smart ptr (deep vs shallow).
Then perhaps you should consider the other examples of similar semantics in the STL. Specifically the clear() and assign() interface of containers. I.e.: o.assign(val); o.clear(); That looks obviously not pointer like to me. And clear enough as to the meaning. But of course it brings to mind the idea that it's just a single value container, and hence possibly should have some more of those interfaces. Just a thought :-) -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org