Function IntrusivePtr.proxySwap

Swap this with rhs

void proxySwap (
  scope ref typeof(this) rhs
) pure nothrow @nogc scope @trusted;

Examples

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

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

{
    IntrusivePtr!Foo a = IntrusivePtr!Foo.make(1);
    IntrusivePtr!Foo b = IntrusivePtr!Foo.make(2);
    a.proxySwap(b);
    assert(a != null);
    assert(b != null);
    assert(a.get.i == 2);
    assert(b.get.i == 1);
    import std.algorithm : swap;
    swap(a, b);
    assert(a.get.i == 1);
    assert(b.get.i == 2);
    assert(a.useCount == 1);
    assert(b.useCount == 1);
}