On Thu, 23 Sep 2010 02:19:55 -0400, Daniel Murphy
<[email protected]> wrote:
"Steven Schveighoffer" <[email protected]> wrote in message
news:[email protected]...
Second, std.algorithm.count looks like this:
size_t count(alias pred = "a == b", Range, E)(Range r, E value) if
(isInputRange!(Range))
So, E can be any type, completely unrelated to strings, I could do:
count!(string, int[]) which makes no sense.
I think the sig should be
size_t count(alias pred = "a == b", Range, E)(Range r, E value) if
(isInputRange!(Range) && isImplicitlyConvertable!(E,
ElementType!(Range)))
-Steve
Except you can call it like this:
string s = "1234";
int[] a = [1, 2, 3];
count!"cast(int)(a - '0') == b.length"(s, a);
Which is perfectly valid.
and insane :)
count(s, cast(char)(a.length + '0'));
-Steve