loop through specific class members
BCS
ao at pathlink.com
Mon Jan 19 13:10:24 PST 2009
Reply to Daniel,
> It depends on what exactly you're trying to do. Some time ago, I
> wrote a library that created XML loaders for structs, and it needed to
> know the names of fields. Pre-traits, this is what I used:
>
> struct Stuff
> {
> int foo;
> char[] bar;
> alias Tuple!("foo", "bar") _fields;
> }
> Then I just looped over _fields.
>
> -- Daniel
>
you can get the names even in D1.0. Not exactly clean but...
http://codepad.org/Eu16XqFu
More information about the Digitalmars-d-learn
mailing list