This currently works, templatizing the delegate type for attribute propagation while still documenting the expected signature:
```
size_t count(T, P : bool delegate(T))(T[] array, P predicate) {
size_t ret;
foreach (e; array)
if (predicate(e))
++ret;
return ret;
}
size_t countOdd(int[] array) @nogc nothrow pure @safe {
return array.count(delegate(int a) => a % 2 == 1);
}
```
But the usage is plain ugly and super-explicit. Inferring parameter types and promoting the function literal to a delegate literal would be a very welcome improvement and enable `array.count(a => a % 2 == 1)`.
Comment #1 by robert.schadek — 2024-12-13T19:19:17Z