opIndexUnary post in-/decrement how to ?

wjoe invalid at example.com
Wed Jul 14 10:07:38 UTC 2021


I'm want to do something like this
```D
part_int_t!(1,2,3) i;

auto x = -i[0];
--i[1]; // 1
i[1]++; // 2

```
I think the operator I need to overload would be opIndexUnary 
which I did.
(1) compiles.
(2) doesn't - the compiler complains that i.opIndex isn't an 
lvalue and can't be modified.
The language spec says that Post in- and decrement are rewritten 
but something's fishy.
What's going on behind the scene and how can I make it work?



More information about the Digitalmars-d-learn mailing list