opIndexUnary post in-/decrement how to ?
Tejas
notrealemail at gmail.com
Thu Jul 15 04:07:49 UTC 2021
On Wednesday, 14 July 2021 at 20:55:32 UTC, wjoe wrote:
> In my particular case the compiler can rule out ```opIndex```
> so why does it abort instead of trying ```opIndexUnary``` ? Or
> was it trying and it didn't work ? If that's the case I'd like
> to know the reason why it discarded ```opIndexUnary```.
>
> Anyways all the answers so far are much appreciated!
Your code
```d
auto x = i[1]++;
```
Expands to:
```d
auto x = (auto e = i[1]/*notice opIndex*/, ++i[1]/* notice
opIndexUnary*/, return e;);
```
This doesn't happen with pre increment. No compiler shenanigans.
Hence your problems.
Please take a look at the library I mentioned previously, it may
help.
More information about the Digitalmars-d-learn
mailing list