Skip to content

Commit d7c1cd6

Browse files
Make const-nonconst conv less cursed.
1 parent 437501c commit d7c1cd6

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

source/numem/mem/ptr.d

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,10 @@ public:
161161
Moves unique_ptr to this instance.
162162
163163
This is a reuse of copy-constructors, and is unique to unique_ptr.
164-
165-
This exists for DMD support.
166164
*/
167165
@trusted
168166
this(ref const(unique_ptr!T) other) {
169-
170-
// Free our own refcount if need be
171-
if (this.rc) {
172-
this.reset();
173-
}
174-
175-
// atomically moves the reference from this unique_ptr to the other unique_ptr reference
176-
// after this is done, rc is set to null to make this unique_ptr invalid.
177-
atomicStore(this.rc, cast(refcountmg_t!(T)*)other.rc);
178-
179-
// For LDC2 we'll need to do some more cursed pointer casts to be able to call clear on a const.
180-
(cast(unique_ptr!(T)*)&other).clear();
167+
this(*(cast(unique_ptr!(T)*)&other));
181168
}
182169

183170
// Destructor

0 commit comments

Comments
 (0)