to

Performs checked conversion from an integral type From to an $(D_KEYWORD enum).

Parameters

From

Source type.

To

Target type.

from From

Source value.

Return Value

Type: To

$(D_KEYWORD enum) value.

Throws

$(D_PSYMBOL ConvException) if from is not a member of $(D_PSYMBOL To).

Examples

enum Test : int
{
    one,
    two,
}
static assert(is(typeof(1.to!Test) == Test));
assert(0.to!Test == Test.one);
assert(1.to!Test == Test.two);

Meta