SmartEnum

Template to mixin a SmartEnum class.

Members

Static variables

SmartEnum
auto SmartEnum;
Undocumented in source.

Parameters

Name

name of class

T

variadic list of one or more SmartEnumValues

Generates output of the form:

class EnumName : ISmartEnum
{
    // class contents (see templates above)
}

Examples

alias SmartEnumValue!(int) Code;

mixin (SmartEnum!("Commands",
    Code("first", 1),
    Code("second", 2)
));

test!("==")(*Commands.description(Commands.first), "first"[]);
test!("==")(*Commands.description(1), "first"[]);

test!("==")(*Commands.code("first"), Commands.first);
test!("==")(*Commands.code("second"), 2);

test((1 in Commands) !is null);
test((Commands.second in Commands) !is null);
test((5 in Commands) is null);

test(("first" in Commands) !is null);
test(("third" in Commands) is null);

size_t count;
foreach ( code, descr; Commands )
    ++count;
test!("==")(count, 2);

Meta