digitalmars.D.learn - Is it valid in D to write an opSlice overload that takes no arguments?
- solidstate1991 (16/16) Sep 11 2022 Here's this code:
- Adam D Ruppe (4/5) Sep 11 2022 This should be allowed, but also the way you're supposed to write
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); } ``` This was originally in std.experimental.xml in `domimpl.d`, and it causes LDC to segfault, but compiles fine under DMD.
Sep 11 2022
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.
Sep 11 2022