Operator "+=" overloading for class?

Ki Rill rill.ki at yahoo.com
Sun Dec 17 04:13:20 UTC 2023


I am trying to overload `opOpAssign` for my class. The code 
compiles, but it does not seem to be working.

```d
// binary operations have already been implemented for Value
// i need +=, -=, *=, /=
auto opOpAssign(string op)(Value rhs)
{
     mixin("return this" ~ op ~ "rhs;");
}

auto opOpAssign(string op)(in ElementType rhs)
{
     mixin("return this" ~ op ~ "rhs;");
}
```

What am I missing here? Full project code can be found 
[here](https://github.com/rillki/tiny-grad).


More information about the Digitalmars-d-learn mailing list