easy way to output a struct?
Hoenir
mrmocool at gmx.de
Wed Jan 14 16:04:15 PST 2009
BCS schrieb:
> http://codepad.org/Eu16XqFu
>
Thank you very much, it works like a charm.
I wrote a small function to log whatever object I pass to it:
void log(T)(T obj)
{
static if (is(T == struct) || is(T == class))
{
writef("{");
foreach(i,_;obj.tupleof)
writefln("%s : %s,", obj.tupleof[i].stringof[4..$], obj.tupleof[i]);
writefln("}");
}
else
{
writefln(obj);
}
}
Are there better solutions than this or does it perhaps have any flaws?
More information about the Digitalmars-d-learn
mailing list