www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20888] New: std.range.Cycle does not compose with `const`

https://issues.dlang.org/show_bug.cgi?id=20888

          Issue ID: 20888
           Summary: std.range.Cycle does not compose with `const`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

```
import std.stdio;
import std.range;

struct Data
{
    char[4096] internal;
    Cycle!(char[4096]) cycle;
    auto get () const { return this.cycle.save(); }
}

void main ()
{
    Data d;
    writeln(d.get().take(10));
}
```

Expectation: 10 characters get printed
Reality:
```
/usr/local/opt/dmd/include/dlang/dmd/std/range/package.d(2231): Error: cannot
implicitly convert expression input of type const(Cycle!(char[4096])) to
Cycle!(char[4096])
foo.d(14): Error: template instance std.range.take!(const(Cycle!(char[4096])))
error instantiating
```

--
May 31