isBitFlagEnum

Determines whether E is a $(D_KEYWORD enum), whose members can be used as bit flags.

This is the case if all members of E are integral numbers that are either 0 or positive integral powers of 2.

Members

Variables

isBitFlagEnum
enum bool isBitFlagEnum;
Undocumented in source.
isBitFlagEnum
enum bool isBitFlagEnum;
Undocumented in source.
isValid
enum bool isValid(OriginalType!E x);
Undocumented in source.

Parameters

E

Some $(D_KEYWORD enum).

Return Value

$(D_KEYWORD true) if E contains only bit flags, $(D_KEYWORD false) otherwise.

Examples

enum Valid
{
    none = 0,
    one = 1 << 0,
    two = 1 << 1,
}
static assert(isBitFlagEnum!Valid);

enum Invalid
{
    one,
    two,
    three,
    four,
}
static assert(!isBitFlagEnum!Invalid);

enum Negative
{
    one = -1,
    two = -2,
}
static assert(!isBitFlagEnum!Negative);

Meta