www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - __traits(getMember, ...) on instance member

reply %u <wfunction hotmail.com> writes:
Hi,

Something has been confusing me, regarding passing around aliases of instance
members.

If I can say:

  struct S { int m; }
  pragma(msg, (S).m);

How come I can't say:

  struct S { int m; }
  pragma(msg, __traits(getMember, S, m));

?
What's the difference, and what does each one mean?

(I'm trying to create a MembersTuple(T) template that returns a tuple of all
members, but this stumbling block is pretty much fatal to my implementation.)

Thank you!
Jan 15 2011
parent %u <wfunction hotmail.com> writes:
Sorry, I just noticed a typo. The line saying
  pragma(msg, __traits(getMember, S, m));
should've said:
  pragma(msg, __traits(getMember, S, "m"));
Jan 15 2011