filter!(not!(predicate))(someInputRange) does not compile
Jens Mueller
jens.k.mueller at gmx.de
Wed Jan 19 17:19:23 PST 2011
Andrei Alexandrescu wrote:
> 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); }
Thanks. Can you elaborate a bit please? I wonder why the alias won't
work.
Jens
More information about the Digitalmars-d
mailing list