comparison lphobos/std/stdio.d @ 22:a6360e68134a trunk

[svn r26] * Fixed templates defining a constant value * Fixed problem with slice-slice copy assignment if a side was a temporary slice
author lindquist
date Thu, 04 Oct 2007 07:35:02 +0200
parents 8d45266bbabe
children 77e3d1ddae3f
comparison
equal deleted inserted replaced
21:8d45266bbabe 22:a6360e68134a
1 module std.stdio; 1 module std.stdio;
2
3 import std.traits;
2 4
3 void _writef(T)(T t) { 5 void _writef(T)(T t) {
4 static if(is(T: Object)) _writef(t.toString()); else 6 static if(is(T: Object)) _writef(t.toString()); else
5 static if(is(T==char)) _writef("%c", t); else 7 static if(is(T==char)) printf("%c", t); else
6 static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else 8 static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else
7 static if(isArray!(T)) { 9 static if(isArray!(T)) {
8 _writef('['); 10 _writef('[');
9 if (t.length) _writef(t[0]); 11 if (t.length) _writef(t[0]);
10 for (int i=1; i<elem.length; ++i) { _writef(','); _writef(t[i]); } 12 for (int i=1; i<t.lengthi; ++i) { _writef(','); _writef(t[i]); }
11 _writef(']'); 13 _writef(']');
12 } else 14 } else
13 static if(is(T==int)) printf("%i", t); else 15 static if(is(T==int)) printf("%i", t); else
14 static assert(false, "Cannot print "~T.stringof); 16 static assert(false, "Cannot print "~T.stringof);
15 } 17 }