IntrusivePtr.opEquals

Operator == and != . Compare pointers.

  1. bool opEquals(typeof(null) nil)
  2. bool opEquals(Rhs rhs)
    struct IntrusivePtr
    const @safe scope pure nothrow @nogc
    bool
    opEquals
    (
    Rhs
    )
    (
    scope auto ref const Rhs rhs
    )
    if (
    !is(Rhs == shared)
    )
  3. bool opEquals(Elm elm)

Examples

static struct Foo{
    ControlBlock!(int, int) c;
    int i;

    this(int i)pure nothrow @safe @nogc{
        this.i = i;
    }
}

{
    IntrusivePtr!Foo x = IntrusivePtr!Foo.make(0);
    assert(x != null);
    x = null;
    assert(x == null);
}

{
    IntrusivePtr!Foo x = IntrusivePtr!Foo.make(123);
    IntrusivePtr!Foo y = IntrusivePtr!Foo.make(123);
    assert(x == x);
    assert(y == y);
    assert(x != y);
}

{
    IntrusivePtr!Foo x;
    IntrusivePtr!(const Foo) y;
    assert(x == x);
    assert(y == y);
    assert(x == y);
}

{
    IntrusivePtr!Foo x = IntrusivePtr!Foo.make(123);
    IntrusivePtr!Foo y = IntrusivePtr!Foo.make(123);
    assert(x == x.element);
    assert(y.element == y);
    assert(x != y.element);
}

Meta