Class Data Members Name Reflection

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 10 09:10:08 PDT 2014


Is there a way to iterate over the symbolic names of the data 
members of a class instance?

I'm currently using .tupleof to get its values (and in turn 
types) to implement   pretty printing to multiple backends 
(currently testing HTML) using as much of D's compile time 
reflection as possible:

https://github.com/nordlow/justd/blob/master/pprint.d

I've currently defined mappings from InputRanges of Aggregates 
(tuples, structs, and classes) to HTML tables where

- the aggregate members are mapped to table columns (and their 
types in turn two column headers) and
- range elements to rows

and I would like to perfect the output by also propagating the 
member names to the column headings.

I'm aware of __traits(allMembers, Type) but those return more 
than .tupleof does.

Help please.


More information about the Digitalmars-d-learn mailing list