isOrderedEnum

Indicates wether an enum is ordered.

An enum is considered as ordered if its members can index an array, optionally with a start offset.

template isOrderedEnum (
T
) if (
is(T == enum)
) {
enum isOrderedEnum;
enum isOrderedEnum;
}

Parameters

T

enum to be tested.

Return Value

true if T members type is integral and if the delta between each member is one, false otherwise.

Examples

1 enum A {a,z,e,r}
2 static assert(isOrderedEnum!A);
3 enum B: ubyte {a = 2,z,e,r}
4 static assert(isOrderedEnum!B);
5 
6 enum C: float {a,z,e,r}
7 static assert(!isOrderedEnum!C);
8 enum D: uint {a,z = 8,e,r}
9 static assert(!isOrderedEnum!D);

Meta