enumToString

Convenience wrapper around Enum that infers the type of the passed enum member.

@safe
enumToString
(
E
)
(
const E value
)
if (
is(E == enum)
)

Parameters

value E

Enum member whose string name we want.

Return Value

Type: auto

The string name of the passed enum member.

Examples

enum T
{
    UNSET,
    QUERY,
    PRIVMSG,
    RPL_ENDOFMOTD
}

with (T)
{
    static assert(enumToString(QUERY) == "QUERY");
    static assert(enumToString(PRIVMSG) == "PRIVMSG");
    static assert(enumToString(RPL_ENDOFMOTD) == "RPL_ENDOFMOTD");
}

See Also