filter!(not!(predicate))(someInputRange) does not compile
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Jan 19 17:08:33 PST 2011
On 1/19/11 5:53 PM, Jens Mueller wrote:
> Hi,
>
> I cannot make the following compile.
>
> import std.functional;
> import std.array;
> import std.algorithm;
> import std.stdio;
>
> void main() {
> auto numbers = [0, 1, 2, 3, 4, 5];
>
> bool alwaysTrue(uint a) { return true; }
> alias not!(alwaysTrue) alwaysFalse;
>
> numbers = array(filter!(alwaysTrue)(numbers));
> writeln(numbers);
> numbers = array(filter!(alwaysFalse)(numbers)); // does not compile
> writeln(numbers);
> }
>
> The line with alwaysFalse fails with:
> /path/to/../src/phobos/std/algorithm.d(854): Error: constructor
> std.algorithm.Filter!(not,int[]).Filter.this cannot get frame pointer to
> not
>
> Any ideas what I'm doing wrong or workarounds?
>
> Jens
Place the call to not!alwaysTrue in a local function inside main:
bool alwaysFalse(uint a) { return not!alwaysTrue(a); }
Andrei
More information about the Digitalmars-d
mailing list