No implicit opOpAssign for structs with basic types?

Robert M. Münch robert.muench at saphirion.com
Sat Apr 4 12:14:23 UTC 2020


On 2020-04-04 10:32:32 +0000, Ferhat Kurtulmuş said:

> struct S {
>      float a;
>      float b;
> 
>      S opOpAssign(string op)(ref S rhs) if (op == "+"){
>          this.a += rhs.a;
>          this.b += rhs.b;
>          return this;
>      }
> }

If the struct is from some 3rd party source, how can I add such an 
operator overloading to it? Is it possible to "extend" a struct later?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list