mask

Masks, at compile-time, a byte, a nibble or a bit in the argument.

  1. auto mask(T value)
    nothrow @safe pure
    mask
    (
    size_t index
    T
    )
    (
    const T value
    )
    if (
    (
    kind == MaskKind.Byte &&
    index <= T.sizeof
    )
    ||
    (
    kind == MaskKind.Nibble &&
    index <= T.sizeof * 2
    )
    ||
    (
    kind == MaskKind.Bit &&
    index <= T.sizeof * 8
    )
    )
  2. auto mask(T value, size_t index)

Parameters

index

the position, 0-based, of the element to mask.

kind

the kind of the element to mask.

value T

the value mask.

Return Value

Type: auto

The input argument with the element masked.

Examples

// MaskKind.Byte by default.
static assert(mask!1(0x12345678) == 0x12340078);
static assert(mask!(1,MaskKind.Nibble)(0x12345678) == 0x12345608);

Meta