Quote:Original post by rozz666
So now, that we agree that it doesn't make sense, we need to find out what's the standard says about it. It means buying ANSI sheet or Comeau compiler, so I hope someone in this forum hopefully has one of these?
There's also the
standard draft, which is freely available online.
In particular:
Quote:13.5.5 §1
operator[] shall be a non-static member function with exactly one
parameter. It implements the subscripting syntax
postfix-expression [ expression ]
Thus, a subscripting expression x[y] is interpreted as x.operator[](y)
for a class object x of type T if T::operator[](T1) exists and if the
operator is selected as the best match function by the overload reso-
lution mechanism (_over.match.best_).
And:
Quote:13.3.1.2
§4 For the built-in assignment operators, conversions of the left operand
are restricted as follows:
--no temporaries are introduced to hold the left operand, and
--no user-defined conversions are applied to the left operand to
achieve a type match with the left-most parameter of a built-in can-
didate.
§5 For all other operators, no such restrictions apply.
Hm. So, for every possible conversion, the compiler determines if an user-defined or built-in operator exists, and chooses the least ambiguous one, and the = operator is restricted.
I have to leave now, so I'll let the rest of the reading to you. [smile]