Function GlobalPtr.opCmp

Operators <, <=, >, >= for RcPtr.

sizediff_t opCmp (
  typeof(null) nil
) const pure nothrow @nogc scope @trusted;

sizediff_t opCmp(Elm) (
  scope const Elm elm
) const pure nothrow @nogc scope @trusted
if (is(Elm : GetElementReferenceType!(typeof(this))));

sizediff_t opCmp(Rhs) (
  auto scope const ref Rhs rhs
) const pure nothrow @nogc scope @trusted
if (isGlobalPtr!Rhs && !is(Rhs == shared));

Compare address of payload.

Examples

{
    const GlobalPtr!long a = new long(42);
    const GlobalPtr!long b = new long(123);
    const GlobalPtr!long n = GlobalPtr!long.init;

    assert(a <= a);
    assert(a >= a);

    assert((a < b) == !(a >= b));
    assert((a > b) == !(a <= b));

    assert(a > n);
    assert(a > null);

    assert(n < a);
    assert(null < a);
}

{
    const GlobalPtr!long a = new long(42);
    const GlobalPtr!long b = new long(123);

    assert(a <= a.element);
    assert(a.element >= a);

    assert((a < b.element) == !(a.element >= b));
    assert((a > b.element) == !(a.element <= b));
}