Operator overloading through UFCS doesn't work
Jonathan M Davis
jmdavisProg at gmx.com
Sat Oct 13 02:26:20 PDT 2012
On Saturday, October 13, 2012 11:06:27 Jakob Ovrum wrote:
> On Saturday, 13 October 2012 at 08:36:19 UTC, Tommi wrote:
> > Quote from TDPL: "D’s approach to operator overloading is
> > simple: whenever at least one participant in an operator
> > expression is of user-defined type, the compiler rewrites the
> > expression into a regular method call with a specific name.
> > Then the regular language rules apply."
>
> Do note that this says *method* call. Your example doesn't use
> methods. Hence, the current state of operator overloading is
> consistent with TDPL.
Yes. It is most definitely illegal to overload any operators as free functions.
They're _always_ member variables of the type that they operate on.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list