[Issue 5491] New: filter cannot be used in a function?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 26 10:38:39 PST 2011


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

           Summary: filter cannot be used in a function?
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: tbolsh at gmail.com


--- Comment #0 from Timofei Bolshakov <tbolsh at gmail.com> 2011-01-26 10:36:32 PST ---
The following code:
_______________________________________________________________________________
import std.algorithm, std.conv, std.stdio;

enum UsbDevType: uint { indifferent = 0, parent_of_checked = 1, hub_dub_7 =
0x2001f103, spider_hub = 0x05e30608, gateway = 0x11A03232 }
struct UsbDevice { //{{{ 
    UsbDevType dev_type;
    // not essential here ...
    string toString(){ return to!string( dev_type ); }
}

UsbDevice [] gateways_only( UsbDevice []devices ){ return filter!("a.dev_type
== UsbDevType.gateway" )( devices ); }

unittest{
    auto devices  = [ UsbDevice( UsbDevType.gateway ), UsbDevice(
UsbDevType.indifferent ), UsbDevice( UsbDevType.hub_dub_7 ) ];
    auto gateways = gateways_only( devices );
    foreach( UsbDevice dev; gateways ) writeln( dev.toString() );
}
______________________________________________________________________________
does not compile telling:
bugs/tbolsh_d2_bug2.d(10): Error: cannot implicitly convert expression
(filter(devices)) of type Filter!(result,UsbDevice[]) to UsbDevice[]

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