reduceSentinel

This function converts an array to a SentinelArray. It requires that the last element array[$-1] be equal to the sentinel value. This differs from the function asSentinelArray which requires the first value outside of the bounds of the array array[$] to be equal to the sentinel value. This function does not require the array to "own" elements outside of its bounds.

  1. auto reduceSentinel [@property getter]
    @property @trusted
    reduceSentinel
    (
    T
    )
    (
    T[] array
    )
  2. auto reduceSentinel [@property getter]

Examples

auto s1 = "abc\0".reduceSentinel;
assert(s1.length == 3);
() @trusted {
    assert(s1.ptr[s1.length] == '\0');
}();

auto s2 = "foobar-".reduceSentinel!'-';
assert(s2.length == 6);
() @trusted {
    assert(s2.ptr[s2.length] == '-');
}();

Meta