address4

Constructs an $(D_PSYMBOL Address4) from raw bytes in network byte order.

  1. Nullable!Address4 address4(R range)
  2. Nullable!Address4 address4(R range)
    Nullable!Address4
    address4
    (
    R
    )
    ()
    if (
    isInputRange!R &&
    is(Unqual!(ElementType!R) == ubyte)
    )

Parameters

R

Input range type.

range R

$(D_KEYWORD ubyte) range containing the address.

Return Value

Type: Nullable!Address4

$(D_PSYMBOL Nullable) containing the address if the range contains exactly 4 bytes, or nothing otherwise.

Examples

{
    ubyte[4] actual = [127, 0, 0, 1];
    assert(address4(actual[]).get.isLoopback());
}
{
    ubyte[3] actual = [127, 0, 0];
    assert(address4(actual[]).isNull);
}
{
    ubyte[5] actual = [127, 0, 0, 0, 1];
    assert(address4(actual[]).isNull);
}

Meta