[Issue 15139] New: allow foreach over Range*
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Fri Oct  2 12:39:09 PDT 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15139
          Issue ID: 15139
           Summary: allow foreach over Range*
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: john.loughran.colvin at gmail.com
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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list