Function IntrusivePtr.opEquals
Operator == and != . Compare pointers.
bool opEquals
(
typeof(null) nil
) const pure nothrow @nogc scope @safe;
bool opEquals(Rhs)
(
auto scope const ref Rhs rhs
) const pure nothrow @nogc scope @safe
if (isIntrusivePtr!Rhs && !is(Rhs == shared));
bool opEquals(Elm)
(
scope const Elm elm
) const pure nothrow @nogc scope @safe
if (is(Elm : GetElementReferenceType!(typeof(this))));
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);
}