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: nob...@puremagic.com ReportedBy: tbo...@gmail.com --- Comment #0 from Timofei Bolshakov <tbo...@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: -------