
"Fernando Cacciola" <fernando_cacciola@hotmail.com> writes:
This is not the way assignment of reference types work in C++:
ra = rb ; // The value of 'a' referenced by 'ra' is changed, not the reference itself. cout << a ; Prints 789
This error in the way optional<T&> treated assignment of reference types was pointed out by Joel de Guzman long ago when he started using Optional in Spirit. However, at the time, Joel explicitely asked me not to change this and keep the current rebinding semantics in order to minimize any impact in Spitit itself (which certainly has, o had, a much larger user base).
If I change the code now to use T's operator=(), assignment of optional<T&> will have a _radically_ different semantics. A correct one, that's for sure, but end user code might be fundamentally impacted.
You might want to consider whether it makes sense to change the semantics only for non-reference types. -- Dave Abrahams Boost Consulting www.boost-consulting.com