On Thu, 15 Jan 2009 03:04:15 +0300, Hoenir <[email protected]> wrote:
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?
One note is that you should probably pass the object by reference:
void log(T)(ref T obj) { ... } // D1
void log(T)(ref const(T) obj) { ... } // D2