Traits in a template enum
Some Guy
someguy at mailinator.com
Sun Oct 10 12:39:17 UTC 2021
I have this enum to get the type of a member field in a struct:
`enum typeOfMember(T, string member) = typeof(__traits(getMember,
T, member));`
I'm having problems when I try to used it though. For example:
```D
writeln(typeOfMember!(T, member).stringof); // Doesn't work:
Error: initializer must be an expression, not `int[]`
writeln(typeof(__traits(getMember, T, member)).stringof); //
Expand the enum, it works.
```
What is the problem here? I'm using the LDC 1.27.1.
More information about the Digitalmars-d-learn
mailing list