Whats the best way to get a struct/class member type?

Jacob Carlborg doob at me.com
Sat Mar 31 08:30:40 PDT 2012


On 2012-03-31 15:20, simendsjo wrote:
> Seems __traits doesn't have a __traits(getMemberType, T, name).
> Now I'm doing the following:
> T t; // instance to use in getMember
> alias typeof( __traits(getMember, t, name) ) MemberType;
>
> Is this the only way to get the type of a field based on the name?

You could use .tupleof, but I don't think that would be any better.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list