diff --git a/source/numem/mem/ptr.d b/source/numem/mem/ptr.d index ebc2950..161b5c9 100644 --- a/source/numem/mem/ptr.d +++ b/source/numem/mem/ptr.d @@ -153,10 +153,29 @@ public: // atomically moves the reference from this unique_ptr to the other unique_ptr reference // after this is done, rc is set to null to make this unique_ptr invalid. atomicStore(this.rc, other.rc); - this.rc = other.rc; other.clear(); } + /** + Moves unique_ptr to this instance. + + This is a reuse of copy-constructors, and is unique to unique_ptr. + + This exists for DMD support. + */ + this(ref const(unique_ptr!T) other) { + + // Free our own refcount if need be + if (this.rc) { + this.reset(); + } + + // atomically moves the reference from this unique_ptr to the other unique_ptr reference + // after this is done, rc is set to null to make this unique_ptr invalid. + atomicStore(this.rc, cast(refcountmg_t!(T)*)other.rc); + atomicStore(other.rc, null); + } + // Destructor ~this() { diff --git a/source/numem/mem/vector.d b/source/numem/mem/vector.d index e1fef92..d7bd066 100644 --- a/source/numem/mem/vector.d +++ b/source/numem/mem/vector.d @@ -108,7 +108,7 @@ public: /** Moves non-copyable members of one vector to another */ - this(ref return scope vector!T rhs) { + this(ref vector!T rhs) { if (rhs.memory) { this.resize_(rhs.size_); foreach(i; 0..rhs.size_) { @@ -125,7 +125,7 @@ public: /** Makes a copy of a vector */ - this(ref return scope vector!T rhs) { + this(ref vector!T rhs) { if (rhs.memory) { this.resize_(rhs.size_); this.memory[0..size_] = rhs.memory[0..rhs.size_];