On Wednesday, 14 July 2021 at 15:23:05 UTC, vit wrote:
On Wednesday, 14 July 2021 at 15:19:03 UTC, vit wrote:


```d
import   std.stdio;

struct abc{
    int[100] a;

    struct Proxy{
        abc* ptr;
        const int index;

        int opUnary(string op : "++")(){
                return ++ptr.a[index];     //add missing ++
        }
    }

    Proxy opIndex(int index)return{
        return Proxy(&this, index);
    }
}

void main (){
    abc s;
    s[0]++;
    ++s[0];
}


```

The ```post increment``` still doesn't work :(

this is the output for your code:
```
Proxy(7FFC7ACB3E60, 0)
2
```
And if the add the following statements:
```d

writeln(s[0]++);
    writeln(s[0]);
    writeln(s[0]++);
    writeln(s[0]);
    writeln(++s[0]);
```

Output:
```
Proxy(7FFCBE3CAF20, 0)
Proxy(7FFCBE3CAF20, 0)
Proxy(7FFCBE3CAF20, 0)
Proxy(7FFCBE3CAF20, 0)
3

```

Reply via email to