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

           Summary: Take, Chain on top of ranges w/o moveFront()
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: dsim...@yahoo.com


--- Comment #0 from David Simcha <dsim...@yahoo.com> 2010-06-13 11:51:14 PDT ---
import std.range;

struct CountRange {
    uint num;

    uint front() {
        return num;
    }

    void popFront() {
        num++;
    }

    bool empty() @property {
        return num == uint.max;
    }

    typeof(this) save() @property {
        return this;
    }
}

void main() {
    CountRange cr;
    auto t = take(cr, 100); 
}

This produces a compile time error:
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1289): Error: template
std.range.moveFront(R) if (is(typeof(&r.front()) == ElementType!(R)*)) does not
match any function template declaration
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1289): Error: template
std.range.moveFront(R) if (is(typeof(&r.front()) == ElementType!(R)*)) cannot
deduce template function from argument types !()(CountRange)

Similar results occur when the main block looks like this instead:

void main() {
    CountRange cr1;
    CountRange cr2;
    auto c = chain(cr1, cr2);
}

I guess the correct fix is to just stick moveFront() in a static if block and
disable it for ranges that don't have lvalue elements.  However, I'd like to
get some comments in case I'm misunderstanding the issue here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to