tell if __traits(allMembers, ... ) is an enum (not manifest constant)

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 24 20:32:24 PST 2016


On Thursday, 25 February 2016 at 04:25:25 UTC, Nicholas Wilson 
wrote:
> foreach(m; __traits(allMembers, ...)
> {
>     static if(is(m== enum))
> }


That's close but not quite there... try

static if(is(typeof(__traits(getMember, Item, m)) == enum))

for member variables, or if you are looking at a type itself 
youcan leave off the typeof() bit.


More information about the Digitalmars-d-learn mailing list