[Issue 5691] New: walkLength() compatible with opApply()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 3 12:45:30 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5691

           Summary: walkLength() compatible with opApply()
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-03-03 12:42:36 PST ---
std.range.walkLength() has to return the length of any collection or lazy
iterable that has a length property or is iterable, like a struct with
opApply():


import std.range: walkLength;
struct Iter {
    int stop;
    int opApply(int delegate(ref int) dg) {
        int result;
        foreach (i; 0 .. stop) {
            result = dg(i);
            if (result) break;
        }
        return result;
    }
}
void main() {
    assert(walkLength(Iter(10)) == 10);
}


But DMD 2.052 gives:
test.d(14): Error: template std.range.walkLength(Range) if
(isInputRange!(Range)) does not match any function template declaration
test.d(14): Error: template std.range.walkLength(Range) if
(isInputRange!(Range)) cannot deduce template function from argument types
!()(Iter)

-- 
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