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

solidstate1991 laszloszeremi at outlook.com
Sun Sep 11 09:47:34 UTC 2022


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.


More information about the Digitalmars-d-learn mailing list