give below template struct, how can I list the members x, y and z? I've tried something with OriginalType and TemplateOf but no luck... it seems if I do foo!"str1" the "str1" became "part of type"? give .stringof from typeof(__traits(getMember, foo, field)) I thought the type would be foo!string or something.

Here's the code:

template foo(string s = null)
{
        @nogc
        struct foo
        {
                int n;

                enum x = foo!"str1"(10);
                enum y = foo!"str2"(20);
                enum z = foo!"str3"(30);

                enum myEnum { none }

                void someMethod() { }
        }
}

not working listener:

void list()
{
        static foreach(field; __traits(allMembers, foo!()))
        {{
                alias m = __traits(getMember, foo!(), field);
static if(!isType!m && __traits(isSame, OriginalType!(typeof(m)), foo))
                {
                        writefln("field = [%s]", field);
                }
        }}
}


Reply via email to