On 4/9/11, Robert Clipsham <rob...@octarineparrot.com> wrote: > 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/ >
That's great, I can use it to print out all the fields. Thanks!