filter (taken from on-line doc example) fails to compile
text/x-dsrc
278
Comments
Comment #0 by jays1y — 2010-12-08T15:57:07Z
Created attachment 843
filter (taken from on-line doc example) fails to compile
Platforms: Linux64 (Ubuntu 10.04), Vista(32)
dmd version: 2.050
The following code (as filtertest.d [attached]) will not compile:
// -------------------------------------
import std.stdio;
import std.algorithm;
void main() {
int[] arr = [ 1, 2, 3, 4, 5 ];
// Sum all elements
auto small = filter!("a < 3")(arr);
assert(small == [ 1, 2 ]);
}
//--------------------------------------
d$ dmd filtertest
filtertest.d(8): Error: incompatible types for ((small) == ([1,2])):
'Filter!(result,int[])' and 'int[]'
Note that the code section is cut&paste from
<http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#filter>
Similar code using delegate also doesn't work. I'd attach, but bug tracker only
allows one file attachment(?).
Comment #1 by dsimcha — 2011-04-12T16:26:10Z
This appears to have been fixed in Git but not marked as such.