Why Strings as Classes?

Walter Bright newshound1 at digitalmars.com
Tue Aug 26 02:27:53 PDT 2008


superdan wrote:
> for example look at this fn from std.string.
> 
> int cmp(C1, C2)(in C1[] s1, in C2[] s2);
> 
> so it looks like cmp accepts arrays of any character type. that is
> cool but the [] limits the thing to builtin arrays. the correct sig
> is
> 
> int cmp(S1, S2)(in S1 s1, in S2 s2) if (isSortaString!(S1) &&
> isSortaString!(S2));
> 
> correct?


Yes. It's just that template constraints came along later than 
std.string.cmp :-)



More information about the Digitalmars-d mailing list