importing std.algorithm breaks std.string.count

Daniel Murphy yebblies at nospamgmail.com
Wed Sep 22 23:19:55 PDT 2010


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:op.vi64pdhveav7ka at localhost.localdomain...
> 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. 




More information about the Digitalmars-d-learn mailing list