UFCS

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 15 22:55:53 PDT 2015


On Friday, May 15, 2015 21:31:35 Manfred Nowak via Digitalmars-d-learn wrote:
> The following gives:
> "Error: 'a += b' is not a scalar, it is a C"
> although UFCS should engage.
>
> -manfred
>
> class C{}
> int main(){
>   void opOpAssign( string op)( C a, C b){
>   }
>   C a, b;
>   a+= b;
> }

Overloaded operators have to be defined as part of the type that they're
overloading the operator for, and UFCS is only ever used with the . syntax.
So, this isn't a bug.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list