Getting object members

Szymon Gatner noemail at gmail.com
Wed Jun 12 03:59:40 PDT 2013


Hi,

I am trying to get members of a class via pointer to Object.

I know how to iterate over members when type is known at compile 
time (with __traits) but I can't find a documentation of how to 
get them polymorphically, I mean:

class Foo
{
   int x, y;
}

Object o = new Foo();
auto ci = o.classinfo;

// what to do now to get members?

I found a solution that called getMembers() on ci object but I am 
getting compilation error when trying to call it. I would also 
like to be able to check access level of members as with 
__traits().

Also: Is there any article / tutorial on D's introspection 
capabilities. I heard it is pretty powerful and I would really 
like to try it.

Regards,
Szymon


More information about the Digitalmars-d-learn mailing list