Re: Is it valid in D to write an opSlice overload that takes no arguments?

2022-09-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:47:34 UTC, solidstate1991 wrote: Here's this code: This should be allowed, but also the way you're supposed to write it now is a no-argument opIndex.

Is it valid in D to write an opSlice overload that takes no arguments?

2022-09-11 Thread solidstate1991 via Digitalmars-d-learn
Here's this code: ```d auto opSlice() { struct Range { Attr currentAttr; auto front() { return currentAttr; } void popFront() { currentAttr = currentAttr._nextAttr; } bool empty() { return currentAttr is null; } } return Range(firstAttr); } ```