Hi, I just saw this line:

https://github.com/dlang/dmd/blob/master/druntime/src/core/stdcpp/vector.d#LL66C5-L66C39
```
66: ref inout(T) opIndex(size_t index) inout pure nothrow @safe @nogc { return as_array[index]; }
```

I'm wondering if the `ref` and `inout` redundant here? They both mean the same thing? in C++ terms both return the reference of the i-th element? so only one of them should be enough?

If not, can someone help to explain the difference? the following 4 return types:

1) `ref T` alone
2) `inout T` alone
3) `ref inout(T)`
4) `inout ref(T)`


BTW, what does the second `inout` before `pure` do? it's also redundant?

Thanks.

Reply via email to