string is rarely useful as a function argument

Adam D. Ruppe destructionator at gmail.com
Thu Dec 29 07:14:16 PST 2011


On Thursday, 29 December 2011 at 06:09:17 UTC, Andrei 
Alexandrescu wrote:
> Nah, that still breaks a lotta code because people parameterize 
> on T[], use isSomeString/isSomeChar etc.

/* snip struct string */

import std.traits;
void tem(T)(T t) if(isSomeString!T) {}
void tem2(T : immutable(char)[])(T t) {}

string a = "test";
tem(a); // works
tem2(a); // works


It's the alias this magic again.

(btw I also tried renaming struct string to
struct STRING, and it still worked, so it wasn't
just naming coincidence!)


More information about the Digitalmars-d mailing list