Type inference + forwarding lambda predicate

Jacob Carlborg doob at me.com
Fri Jan 4 08:06:38 PST 2013


The following code results in a Segmentation fault: 11. The reason seems 
to be because "any" is called indefinitely. But if I don't use type 
inference for the lambda it works correctly.

import algorithm = std.algorithm;

bool any (alias predicate, Range) (Range range)
{
     return algorithm.any!(predicate)(range);
}

void main ()
{
     auto arr = ["foo"];
     any!(e => e == "asd")(arr); // segfault
     // any!((string e) => e == "asd")(arr); // works
}

Am I doing something wrong or is this a bug?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list