The OpenD Programming Language

to

The to template converts a value from one type to another. The source type is deduced and the target type must be specified, for example the expression to!int(42.0) converts the number 42 from double to int. The conversion is "unsafe", i.e., it does not check for overflow.

template to(T)
ref
T
to
(
A...
)
(
auto ref A args
)
if (
A.length > 0
)

Members

Functions

to
T to(A args)

Examples

enum E
{
    A,
    B,
    C,
}

assert(to!E("B") == E.B);
assert(to!string(E.B) == "B");
assert(to!string(null) is null);
assert(to!string(true) == "true");
assert(to!string(false) == "false");

enum S : wstring
{
    a = "A",
    b = "B",
}

assert(to!wstring(S.b) == "B"w);
assert(to!S("B"w) == S.b);

Meta