On Tuesday, 3 October 2023 at 13:07:00 UTC, Steven Schveighoffer
wrote:
Now, you can define a further `opIndexAssign(T val, size_t
idx)`. However, now you lose capabilities like `a[0]++`, which
I don't think has a possibility of implementing using an
`opIndex` operator, and it would be pretty ugly if you had to.
Works for me, with both `++` and `+=`:
https://run.dlang.io/is/JckTVG
AST output confirms that these are lowered to use `opIndex`.
Looking at the spec, it seems like `opIndex` would only be
pre-empted here if you overloaded `opIndexUnary` (for `++`)
and/or `opIndexOpAssign` (for `+=`).