
On 3 September 2011 21:55, Mostafa <mostafa_working_away@yahoo.com> wrote:
Because for optional<T&>, and only for optional<T&>, the semantics of the assignment operator differs from the semantics of the assignment operator of its underlying type, namely T&. (Hence the reason for me wanting to explore disallowing the assignment operator for optional<T&>.)
boost::optional is very consistent with respect to assignment. Given boost::optional<T> ot; 'ot = u' deals with the existence of the underlying object, while '*ot = v' deals with the value of the underlying object. Now, in C++, there is no such thing as existence without value, so you cannot escape dealing with the underlying value in the expression 'ot = u'. That holds for non-reference types as well as for references. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404