The following program does not compile:
import std.stdio;
import std.algorithm;
struct A
{
struct S
{
int x;
}
const bool foo(in S s, in int k)
{
return s.x<k;
}
void bar()
{
[S(1),S(2),S(3),S(4),S(5)].filter!(a=>a.foo(3)).writeln;
}
}
void main()
{
A().bar();
}
I get (using rdmd):
test.d(18): Error: no property foo for type S
/usr/include/dmd/phobos/std/algorithm/iteration.d(1108):
instantiated from here: >FilterResult!(__lambda1, S[])
test.d(18): instantiated from here: filter!(S[])
When I replace the UFCS-Syntax in the lambda by a function call
it works:
[S(1),S(2),S(3),S(4),S(5)].filter!(a=>foo(a,3)).writeln;
Where is my mistake?