How do you find the struct types in a module? - getting Error: unknown
aliak
something at something.com
Thu Feb 13 18:11:14 UTC 2020
On Thursday, 13 February 2020 at 15:38:37 UTC, Steven
Schveighoffer wrote:
> On 2/13/20 9:47 AM, aliak wrote:
>>[...]
>
> Not sure about your error, but here is a working version (don't
> use mixins, use __traits(getMember)):
>
> import std.meta;
> template ListOfStructs(alias mod)
> {
> enum isStruct(string m) = is(__traits(getMember, mod, m) ==
> struct);
> alias getMember(string m) = __traits(getMember, mod, m);
> alias ListOfStructs = staticMap!(getMember,
> Filter!(isStruct, __traits(allMembers, mod)));
> }
>
> -Steve
It works without the mixin indeed! Thank you!
More information about the Digitalmars-d-learn
mailing list