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
Type: IT

A reference to an IT.

Return Value

Type: auto

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

Examples

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

Meta