Function Vector.owns

Returns true if memory referenced by p is owned by vector.

bool owns(T) (
  scope const T* p
) const pure nothrow @nogc scope @trusted;

Examples

Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3, 4, 5, 6);

{
    assert(vec.owns(vec.ptr + 3));
    assert(!vec.owns(cast(int*)null));
    assert(!vec.owns(vec.ptr + 100));
}

{
    assert(vec.owns(&vec[$-1]));
    assert(!vec.owns(cast(long*)&vec[$-1]));
}