Mercurial > projects > ldc
comparison lphobos/std/stdio.d @ 21:8d45266bbabe trunk
[svn r25] * Fixed a lot of problems with string literals
* Fixed slice-slice copying assignment
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 07:01:15 +0200 |
parents | c05ef76f1c20 |
children | a6360e68134a |
comparison
equal
deleted
inserted
replaced
20:42bf2eb2973b | 21:8d45266bbabe |
---|---|
1 module std.stdio; | 1 module std.stdio; |
2 | 2 |
3 void _writef(T)(T t) { | 3 void _writef(T)(T t) { |
4 //static if(is(T: Object)) _writef(t.toString()); else | 4 static if(is(T: Object)) _writef(t.toString()); else |
5 static if(is(T==char)) _writef("%c", t); else | |
5 static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else | 6 static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else |
7 static if(isArray!(T)) { | |
8 _writef('['); | |
9 if (t.length) _writef(t[0]); | |
10 for (int i=1; i<elem.length; ++i) { _writef(','); _writef(t[i]); } | |
11 _writef(']'); | |
12 } else | |
6 static if(is(T==int)) printf("%i", t); else | 13 static if(is(T==int)) printf("%i", t); else |
7 static assert(false, "Cannot print "~T.stringof); | 14 static assert(false, "Cannot print "~T.stringof); |
8 } | 15 } |
9 | 16 |
10 void writef(T...)(T t) { | 17 void writef(T...)(T t) { |