Files
ldc/lphobos/std/stdio.d
Tomas Lindquist Olsen be330878c2 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
Added initial support for CatExp aka 'a ~ b'
Fixed global constant static arrays initialized with string literals
Fixed casting any dynamic array to void*
Fixed new expression with temporary storage
Fixed alias declarations in function scope
Fixed relational comparisons of pointers
2007-10-25 09:02:55 +02:00

26 lines
654 B
D

module std.stdio;
import std.traits;
void _writef(T)(T t) {
static if(is(T: Object)) _writef(t.toString()); else
static if(is(T==char)) printf("%c", t); else
static if(is(T: char[])) printf("%.*s", t.length, t.ptr); else
static if(isArray!(T)) {
_writef('[');
if (t.length) _writef(t[0]);
for (int i=1; i<t.length; ++i) { _writef(','); _writef(t[i]); }
_writef(']');
} else
static if(is(T: int)) printf("%i", t); else
static if(is(T: real)) printf("%f", t); else
static assert(false, "Cannot print "~T.stringof);
}
void writef(T...)(T t) {
foreach (v; t) _writef(v);
}
void writefln(T...)(T t) {
writef(t, "\n");
}