Probably a real simple compile-time reflection question?

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 9 14:12:24 PDT 2016


class C
{
     this(){ _i = 0; _j = 0; }
     void setVar(int i) { _i = i; }
     int getVar() { return _i; }
     int _i;
     int _j;
}

writeln("C");
foreach( i, str; myClassMembers)
{
     writeln("    member ", i, " = ", str);
     TypeInfo ti = typeid(str);
     writeln("    type id is ", ti);
     writeln("    type is ", typeof(str).stringof);
}


C
     member 0 = __ctor
     type id is immutable(char)[]
     type is string
     member 1 = _i
     type id is immutable(char)[]
     type is string
     member 2 = setVar
     type id is immutable(char)[]
     type is string
     member 3 = getVar
     type id is immutable(char)[]
     type is string
      . . .
     the same all the way through the class

I'm trying to get at least the type int for the _i member?  Also, 
is there a way to get __traits(allMembers  to work recursively?  
Say, with struct containing structs.

Thanks,
kyle






More information about the Digitalmars-d-learn mailing list