Enum

Enumeration wrapper that uses optimized conversion to string (via toString member).

@safe
struct Enum (
E
) if (
is(E == enum)
) {
E _enum;
}

Alias This

_enum

Examples

enum X { a,
         b,
         _b = b             // enumerator alias
}
alias EnumX = Enum!X;
assert(EnumX(X.a).toString == "a");
assert(EnumX(X.b).toString == "b");
assert(EnumX(X._b).toString == "b"); // alias encodes to original

See Also

https://forum.dlang.org/thread/ppndhxvzayedgpbjculm@forum.dlang.org?page=1

TODO: Move logic to std.conv.to.

Meta