Operator overloading through UFCS doesn't work

Maxim Fomin maxim at maxim-fomin.ru
Sat Oct 13 23:22:02 PDT 2012


On Saturday, 13 October 2012 at 17:01:27 UTC, Tommi wrote:
> Another way to describe my reasoning...
>
> According to TDPL, if var is a variable of a user-defined type, 
> then:
> ++var
> gets rewritten as:
> var.opUnary!"++"()

Not always. If user-defined type has an alias this to integer 
member, than something different would happen. It would be also 
interesting to see, how operation ++T would differ because 
somebody imported module with opUnary method. Because opUnary 
suits better than alias this, dmd will issue call to that 
function, it it see its declaration.



More information about the Digitalmars-d-learn mailing list