[Issue 4654] New: Cannot overload range iteration against opApply	iteration
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Aug 16 08:21:26 PDT 2010
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=4654
           Summary: Cannot overload range iteration against opApply
                    iteration
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com
--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2010-08-16 08:21:22 PDT ---
The following code doesn't compile even though there is no ambiguity:
struct Range {
    uint num;
    @property uint front() {
        return num;
    }
    void popFront() {
        num++;
    }
    bool empty() {
        return num >= 10;
    }
    int opApply(int delegate(ref int, ref int, ref int) dg) {
        int res;
        foreach(i; 0..10) {
            res = dg(i, i, i);
            if(res) break;
        }
        return res;
    }
}
void main() {
    Range range;
    foreach(elem; range) {}  // Doesn't work.
    foreach(e1, e2, e3; range) {}  // Works if previous line commented out.
}
test.d(28): Error: cannot infer type for elem
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list