Class Data Members Name Reflection

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


> I am not sure I understand the question. Does this help?
>
> struct A
> {
> 	int x;
> 	double y;
> }
>
> void main()
> {
> 	foreach (idx, elem; A.init.tupleof)
> 	{
> 		pragma(msg, __traits(identifier, A.tupleof[idx]));
> 	}
> }
>
> // output:
> // x
> // y

Exactly what I wanted!

BTW: Can DMD serve use file and line location of user defined 
type aswell?

Thx!


More information about the Digitalmars-d-learn mailing list