Re: Why is opIndexAssign replaced by opSlice here?

2021-10-18 Thread Elmar via Digitalmars-d-learn
On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote: What happens here is, the compiler first tries the D2-style rewrite: ```d s.opIndexAssign(arr[1..4], s.opSlice!0(0, 3)) ``` However, that rewrite fails to compile, because your `opSlice` does not take a template argument

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Imperatorn via Digitalmars-d-learn
On Monday, 18 October 2021 at 04:11:18 UTC, Paul Backus wrote: On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote: My guess is that you got into this situation by trying to follow the example in the spec's section on ["Slice Assignment Operator Overloading"][2]. Unfortunately, that

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Paul Backus via Digitalmars-d-learn
On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote: My guess is that you got into this situation by trying to follow the example in the spec's section on ["Slice Assignment Operator Overloading"][2]. Unfortunately, that example is incorrect. [2]:

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 17 October 2021 at 22:52:27 UTC, Elmar wrote: Hello Dear community. I'd like to overload `opIndexAssign` for a struct which wraps around a generic array (so that it can't support `opIndex` due to unknown return type). Broken down as much as possible this is the code: ``` import

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Elmar via Digitalmars-d-learn
Btw, I should have written: `s.opIndexAssign(arr[1..4], s.opSlice(0,3));` But it compiles the same way.

Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Elmar via Digitalmars-d-learn
Hello Dear community. I'd like to overload `opIndexAssign` for a struct which wraps around a generic array (so that it can't support `opIndex` due to unknown return type). Broken down as much as possible this is the code: ``` import std.stdio : writeln; import std.range : ElementType;