Skip to content

Commit

Permalink
Make const-nonconst conv less cursed.
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Apr 9, 2024
1 parent 437501c commit d7c1cd6
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions source/numem/mem/ptr.d
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,10 @@ public:
Moves unique_ptr to this instance.
This is a reuse of copy-constructors, and is unique to unique_ptr.
This exists for DMD support.
*/
@trusted
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);

// For LDC2 we'll need to do some more cursed pointer casts to be able to call clear on a const.
(cast(unique_ptr!(T)*)&other).clear();
this(*(cast(unique_ptr!(T)*)&other));
}

// Destructor
Expand Down

0 comments on commit d7c1cd6

Please sign in to comment.