Probably a real simple compile-time reflection question?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 9 14:35:38 PDT 2016


On Saturday, 9 July 2016 at 21:12:24 UTC, WhatMeWorry wrote:
> foreach( i, str; myClassMembers)

What are you doing to get myClassMembers?

If it is __traits(allMembers), it just gives you the *names* of 
the members. To get the actual thing, you then do 
__traits(getMember, object, str) and can check the type of that.

> Also, is there a way to get __traits(allMembers  to work 
> recursively?  Say, with struct containing structs.

You can always just call it recursively once you get the member :)


More information about the Digitalmars-d-learn mailing list