bitFlags

Creates a $(D_PSYMBOL BitFlags) object initialized with field.

bitFlags
(
E
)
()

Parameters

E

Some $(D_KEYWORD enum).

field E

Bits to be set.

Examples

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));

Meta