dump object

Qian Xu quian.xu at stud.tu-ilmenau.de
Mon Mar 30 08:48:57 PDT 2009

Hi All,

previously I saw an article about how to dump an object with all properties.

void log(T)(T obj) {
  static if (is(T == struct) || is(T == class)){
     foreach(i,_;obj.tupleof) {
       writefln("%s : %s,", obj.tupleof[i].stringof[4..$], obj.tupleof[i]);
  else {

But this function does not work with private attributes of an object.

How to print all public properties of an object?
It would be very useful for debug propose.

Best regards

More information about the Digitalmars-d-learn mailing list