template specialization

Thorsten Kiefer thorstenkiefer at gmx.de
Sat Mar 3 18:45:53 PST 2007


OK, I solved it that way :

char[] toString(T)(T x){
	static if(is(T B == B[])) {
		char[] s;
		s ~= '[';
		if(x.length > 0){
			s ~= toString(x[0]);
			foreach(y;x[1..$]){
				s ~= ',';
				s ~= toString(y);
			}
		}
		s ~= ']';
		return s;
	} else {
		return std.string.toString(x);
	}
}




More information about the Digitalmars-d mailing list