www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9906] New: filter of static opCall

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

           Summary: filter of static opCall
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-04-08 16:59:42 PDT ---
import std.stdio: writeln;
import std.algorithm: map, filter;

struct Seen {
    static bool[int] set;

    static bool opCall(int n) {
        auto result = !!(n in set);
        set[n] = true;
        return result;
    }
}

void main() {
    auto data = [1, 5, 1, 3, 2, 1];
    data.filter!(i => i.Seen).writeln; // OK.
    data.map!Seen.writeln;             // OK.
    data.filter!Seen.writeln;          // Error
}


DMD 2.063alpha gives:

temp.d(18): Error: template instance filter!(Seen) does not match template
declaration filter(alias pred) if (is(typeof(unaryFun!(pred))))

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