[Issue 8715] map, filter, zip, not with functional arrays/associative arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 30 18:15:06 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8715
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|map, filter, zip with |map, filter, zip, not with
|functional |functional
|arrays/associative arrays |arrays/associative arrays
--- Comment #6 from bearophile_hugs at eml.cc 2012-12-30 18:14:53 PST ---
Two more examples:
import std.algorithm: filter;
import std.functional: not;
void main() {
bool[] bad = [true, true, false, false, true, false];
auto items = [0, 1, 2, 3, 4, 5];
auto r1 = items.filter!bad();
auto r2 = items.filter!(not!bad)();
}
...\dmd2\src\phobos\std\algorithm.d(1226): Error: function expected before (),
not bad of type bool[]
...\dmd2\src\phobos\std\algorithm.d(1248): Error: function expected before (),
not bad of type bool[]
...\dmd2\src\phobos\std\algorithm.d(1214): Error: template instance
test.main.FilterResult!(bad, int[]) error instantiating
test.d(6): instantiated from here: filter!(int[])
test.d(6): Error: template instance test.main.filter!(bad).filter!(int[]) error
instantiating
...\dmd2\src\phobos\std\algorithm.d(1226): Error: template
test.main.not!(bad).not does not match any function template declaration.
Candidates are:
...\dmd2\src\phobos\std\functional.d(184):
test.main.not!(bad).not(T...)(T args) if (is(typeof(!unaryFun!(pred)(args))) ||
is(typeof(!binaryFun!(pred)(args))))
...\dmd2\src\phobos\std\algorithm.d(1226): Error: template
test.main.not!(bad).not(T...)(T args) if (is(typeof(!unaryFun!(pred)(args))) ||
is(typeof(!binaryFun!(pred)(args)))) cannot deduce template function from
argument types !()(int)
...\dmd2\src\phobos\std\algorithm.d(1248): Error: template
test.main.not!(bad).not does not match any function template declaration.
Candidates are:
...\dmd2\src\phobos\std\functional.d(184):
test.main.not!(bad).not(T...)(T args) if (is(typeof(!unaryFun!(pred)(args))) ||
is(typeof(!binaryFun!(pred)(args))))
...\dmd2\src\phobos\std\algorithm.d(1248): Error: template
test.main.not!(bad).not(T...)(T args) if (is(typeof(!unaryFun!(pred)(args))) ||
is(typeof(!binaryFun!(pred)(args)))) cannot deduce template function from
argument types !()(int)
...\dmd2\src\phobos\std\algorithm.d(1214): Error: template instance
std.algorithm.FilterResult!(not, int[]) error instantiating
test.d(7): instantiated from here: filter!(int[])
test.d(7): Error: template instance std.algorithm.filter!(not).filter!(int[])
error instantiating
- - - - - - - - - - - - - - - -
import std.algorithm: filter;
struct IsOdd {
static bool opCall(in int n) {
return n % 2 == 1;
}
}
void main() {
auto items = [0, 1, 2, 3, 4, 5, 6, 7, 8];
auto r1 = items.filter!(i => IsOdd(i))(); // OK
auto r2 = items.filter!IsOdd(); // Error.
}
test.d(10): Error: template instance filter!(IsOdd) filter!(IsOdd) 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: -------
More information about the Digitalmars-d-bugs
mailing list