mask

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

  1. auto mask(const T value)
    mask
    nothrow @safe pure
    (
    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(const 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
Type: 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