viewAs

Function allowing "blind" casting to any type of the same size.

No operations on actial value performed. It is just treated as having different type.

These functions don't change type qualifier.

Note: alias this isn't considered while casting in contrary to build-in cast.

Warning: Resulting value may depend on target architecture.

  1. inout(To) viewAs [@property getter]
    @safe pure nothrow @property @system @nogc
    inout(To)
    viewAs
    (
    To
    From
    )
    (
    inout(From) val
    )
  2. inout(To) viewAs [@property getter]

Examples

t
{
	int i = 0;
	i.viewAs!(ubyte[4]) = 3;
	assert(i == 0x03030303

Meta