bruteCast

Allows forbidden casts.

bruteCast
(
OT
IT
)
(
auto ref IT it
)

Parameters

OT

The output type.

IT

The input type, optional, likely to be infered.

it IT

A reference to an IT.

Return Value

Type: auto

the same as cast(OT) it, except that it never fails to compile.

Examples

static immutable array = [0u,1u,2u];
size_t len;
//len = cast(uint) array; // not allowed.
len = bruteCast!uint(array);
assert(len == array.length);

Meta