From d7c1cd6e9e51ba8c3204d5417e646eec43b8cf25 Mon Sep 17 00:00:00 2001 From: LunaTheFoxgirl Date: Tue, 9 Apr 2024 20:57:20 +0200 Subject: [PATCH] Make const-nonconst conv less cursed. --- source/numem/mem/ptr.d | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/source/numem/mem/ptr.d b/source/numem/mem/ptr.d index b85ecbf..77a869c 100644 --- a/source/numem/mem/ptr.d +++ b/source/numem/mem/ptr.d @@ -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