[Issue 12791] .tupleof does not take base class fields into account

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jun 29 21:45:24 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=12791

--- Comment #3 from pabuond at gmail.com ---
ok, sorry, indeed __traits can do it. I know this may be out of place here but
might still be useful for people landing on this page:

-----------
auto b = new B; // B inherits from A
foreach(i, m; __traits(allMembers, B))
    static if (__traits(compiles, to!string(__traits(getMember, b, m))))
        writeln(m, " = ", __traits(getMember, b, m));
-----------

prints 'name = value' for all the fields (inherited or new, static or not,
etc.) of an instance of class B.

--


More information about the Digitalmars-d-bugs mailing list