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

Simen Kjaeraas <simen.kja...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |simen.kja...@gmail.com
         Resolution|---                         |WONTFIX

--- Comment #1 from Simen Kjaeraas <simen.kja...@gmail.com> ---
I assume you meant isInputRange!(Unqual!R) in the first half there.

Now, the problem with this idea is that const(R) generally is not a forward
range, or even an input range, and loosening the constraints really doesn't
make it one.

For a quick example, consider const(int[]) arr. Can I call arr.popFront() to
iterate over it? No, that would need to modify the range, and the range is
const, so I can't. If isForwardRange!(const(int[])) returned true, that would
give the impression that I could indeed change the range, and would wreak havoc
with the whole idea of ranges.

Generally, I would simply suggest using isForwardRange!(Unqual!R), but it seems
that's not enough in your case - you want something like this:

enum bool isConstForwardRange(R) = isForwardRange!(Unqual!R) &&
isForwardRange!(ReturnType!((R r) => r.save));

That's probably too niche to put in Phobos, but it should at least solve your
problem here and how.

--

Reply via email to