Comment #0 by john.loughran.colvin — 2015-10-02T19:39:09Z
We should allow foreach over pointers to range types, or alternatively change std.range.isInputRange to disallow pointers to range types.
Currently we have this:
alias Range = Repeat!int;
static assert(isInputRange!(Range*));
//but
static assert(!isIterable!(typeof(a)*));
//because
static assert(!__traits(compiles, { foreach(_; &a){} }));
so just because you checked whether something is an input range, doesn't mean you can actually use foreach over it.
One way or another, resolving this would deal with https://issues.dlang.org/show_bug.cgi?id=11779 and https://issues.dlang.org/show_bug.cgi?id=15096
Note that pointers to ranges can't pass hasSlicing or IsRandomAccessRange because of course the indexing would be all wrong.
Comment #1 by robert.schadek — 2024-12-13T18:45:02Z