Skip to content

Commit

Permalink
Fix LDC2 builds for unique_ptr moves.
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Apr 9, 2024
1 parent 2d3b8d7 commit 437501c
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions source/numem/mem/ptr.d
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ 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, cast(refcountmg_t!(T)*)other.rc);
atomicStore(other.rc, null);

// 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();
}

// Destructor
Expand Down Expand Up @@ -219,16 +221,6 @@ public:
return rc ? cast(VT)rc.ref_ : null;
}

/**
Gets the value of the unique pointer
Returns null if the item is no longer valid.
*/
@trusted
VT opCast() {
return rc ? cast(VT)rc.ref_ : null;
}

/**
Makes a weak borrow of the unique pointer,
weak borrows do not affect whether the object can be deleted by ref count reaching 0.
Expand Down

0 comments on commit 437501c

Please sign in to comment.