enum E { one = 1 << 0, two = 1 << 1, three = 1 << 2, } // Construct with E.one and E.two set auto flags = bitFlags(E.one | E.two); // Test wheter E.one is set assert(flags & E.one); // Toggle E.one flags ^= E.one; assert(!(flags & E.one)); // Set E.three flags |= E.three; assert(flags & E.three); // Clear E.three flags &= ~E.three; assert(!(flags & E.three));
Creates a $(D_PSYMBOL BitFlags) object initialized with field.