[Issue 4402] New: std.range.Zip doesn't work w/ non-lvalue ranges

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 28 19:28:00 PDT 2010


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

           Summary: std.range.Zip doesn't work w/ non-lvalue ranges
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2010-06-28 19:27:56 PDT ---
import std.range;

/**Random access range based on an array, but w/o assignable or lvalue
 * elements.*/
struct ValArray {
    uint[] stuff;

    @property uint front() {
        return stuff[0];
    }

    void popFront() {
        stuff = stuff[1..$];
    }

    @property bool empty() {
        return stuff.length == 0;
    }

    @property uint back() {
        return stuff[$ - 1];
    }

    void popBack() {
        stuff = stuff[0..$ - 1];
    }

    uint opIndex(size_t index) {
        return stuff[index];
    }

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

    @property size_t length() {
        return stuff.length;
    }
}

void main() {
    auto stuff = ValArray([1u, 2U, 3U]);
    auto myZip = zip(stuff, stuff);
}

Error Msgs: 

d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1720): Error: cannot
implicitly convert expression (&this.ranges._field_field_0.front) of type uint
delegate() to uint*
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1720): Error: cannot
implicitly convert expression (&this.ranges._field_field_1.front) of type uint
delegate() to uint*
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1733): Error: cannot
implicitly convert expression (&this.ranges._field_field_0.back) of type uint
delegate() to uint*
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1733): Error: cannot
implicitly convert expression (&this.ranges._field_field_1.back) of type uint
delegate() to uint*

Zip should detect whether the ranges it's fed offer lvalue access and properly
relay this property.

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