As it is implemented as a struct, Enum.init behaves like lvalue (except it can't be assigned to), see $(DBUGZILLA 8915). I.e. (ref Enum e){ } (Enum.init) compiles.
As it is a struct, op assignment operators are allowed for rvalues, see $(DBUGZILLA 8916). I.e. things like Enum.init |= Enum.a and Enum.a |= Enum.a compiles.
mixin flagEnum!("Access", byte, "read = 2", "write", "execute"); // write == 4, execute == 8 assert(cast(uint) Access.init == 0); assert(cast(uint) Access.write == 4); assert(cast(uint) Access.execute == 8); auto folderAccess = Access.read | Access.execute; auto fileAccess = Access.read | Access.write | Access.execute; fileAccess &= folderAccess; assert(fileAccess == (Access.read | Access.execute)); if(fileAccess) { // have some access } else assert(0); import std.stdio: writeln; writeln(fileAccess & Access.read); // Writes "Access.read" writeln(fileAccess); // Writes "Access.{read|execute}" writeln(fileAccess & Access.write); // Writes "Access.{}"
Creates a set of flags.