On 09/04/2011 18:23, Robert Clipsham wrote:
Off the top of my head (untested):
----
void print(T)(T t) if (is(T == struct) || is(T == class))
{
foreach (i, field; t.tupleof)
{
writefln(T.tupleof[i].stringof ~ " = %s", field);
}
}
----

--
Robert
http://octarineparrot.com/

I forgot to mention... Usage:
---
print(myStruct);
----

It's also simple enough to adapt to just print a given field etc.

--
Robert
http://octarineparrot.com/

Reply via email to