
18 Oct
2005
18 Oct
'05
4:47 p.m.
Anthony Williams <anthony_w.geo@yahoo.com> writes:
How's this for a radical thought --- optional<T> should not be assignable from T. That way, it doesn't matter whether T is a reference, or not.
There's at least some precedent for types that are "immutable except for copy assignment." The assignment from T is really a kind of mutating operation.
Instead, to change the binding, use reset(), and to assign use *.
To make that valid for a null optional, I think operator* would have to return a proxy reference... which is not an altogether bad idea, IMO. -- Dave Abrahams Boost Consulting www.boost-consulting.com