Higher level built-in strings

Walter Bright newshound2 at digitalmars.com
Tue Jul 20 12:19:58 PDT 2010


Jérôme M. Berger wrote:
> 	And what about this one:
> 
> void func(T) (T range) {
>     foreach (elem; range)
>         assert (is (typeof (elem) == ElementType!(T)));
> }
> 
> func ("azerty");
> auto a = [ 1, 2, 3, 4, 5];
> func (a);

You can specialize the template for strings:

void func(T:string)(T range) { ... }


More information about the Digitalmars-d mailing list