enum to flags

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 28 20:31:43 PDT 2015


so I have a bunch of enums (0 .. n) that i also want to represent 
as flags ( 1 << n foreach n ). Is there anyway to do this other 
than a string mixin?

use like:

enum blah
{
     foo,
     bar,
     baz,
}

alias blahFlags = EnumToFlags!blah;

static assert(blahFlags.baz == 1 << blah.baz)


More information about the Digitalmars-d-learn mailing list