[Issue 5575] New: Problem with a map() of a const uniq()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 14 11:05:57 PST 2011


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

           Summary: Problem with a map() of a const uniq()
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-02-14 11:03:24 PST ---
D2 code. map() doesn't modify the input range, so I think this is correct (but
I am not sure if it's correct. A mutable range of immutable items isn't the
same thing as an immutable range):


import std.algorithm;
void main() {
    auto u1 = uniq([1]);
    auto m1 = map!q{ a }(u1); // OK
    const u2 = u1;
    auto m2 = map!q{ a }(u2); // Error
}


DMD 2.051 gives:

...\dmd\src\phobos\std\algorithm.d(109): Error: constructor
std.algorithm.Map!(result,const(Uniq!(pred,int[]))).Map.this (Uniq!(pred,int[])
input) is not callable using argument types (const(Uniq!(pred,int[])))
...\dmd\src\phobos\std\algorithm.d(109): Error: cannot implicitly convert
expression (r) of type const(Uniq!(pred,int[])) to Uniq!(pred,int[])
test4.d(6): Error: template instance std.algorithm.map!(" a
").map!(const(Uniq!(pred,int[]))) error instantiating

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