Skip to content

Commit 600e33d

Browse files
committed
fix rcarray
1 parent 1d9bd10 commit 600e33d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

source/mir/rcarray.d

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct mir_rcarray(T)
127127

128128
/// Extern constructor
129129
pragma(inline, false)
130-
bool initialize(size_t length, uint alignment, bool deallocate, bool initialize) scope @safe nothrow @nogc
130+
bool initialize(size_t length, uint alignment, bool deallocate, bool initialize) scope @system nothrow @nogc
131131
{
132132
return initializeImpl(length, alignment, deallocate, initialize);
133133
}
@@ -149,7 +149,7 @@ struct mir_rcarray(T)
149149

150150
/// Extern constructor
151151
pragma(inline, false)
152-
bool initialize(size_t length, uint alignment, bool deallocate, bool initialize) scope @safe nothrow @nogc
152+
bool initialize(size_t length, uint alignment, bool deallocate, bool initialize) scope @system nothrow @nogc
153153
{
154154
return initializeImpl(length, alignment, deallocate, initialize);
155155
}
@@ -175,7 +175,7 @@ struct mir_rcarray(T)
175175
deallocate = Flag, never deallocates memory if `false`.
176176
initialize = Flag, don't initialize memory with default value if `false`.
177177
+/
178-
this(size_t length, uint alignment = T.alignof, bool deallocate = true, bool initialize = true) @safe @nogc
178+
this(size_t length, uint alignment = T.alignof, bool deallocate = true, bool initialize = true) @trusted @nogc
179179
{
180180
if (!this.initialize(length, alignment, deallocate, initialize))
181181
{
@@ -204,7 +204,7 @@ struct mir_rcarray(T)
204204
+/
205205
static typeof(this) create(V[] values...) @safe @nogc
206206
{
207-
auto ret = typeof(this)(values.length, T.alignof, true, false);
207+
auto ret = typeof(this)(values.length, T.alignof, true, hasElaborateAssign!T);
208208
static if (!hasElaborateAssign!T)
209209
{
210210
()@trusted {
@@ -217,18 +217,19 @@ struct mir_rcarray(T)
217217
import mir.conv: emplaceRef;
218218
auto lhs = ret[];
219219
foreach (i, ref e; values)
220-
lhs[i].emplaceRef(e);
220+
lhs[i] = e;
221221
}
222-
return ret;
222+
import std.algorithm.mutation: move;
223+
return ret.move;
223224
}
224225

225226
static if (!hasIndirections!T)
226227
/++
227228
Contructor is defined if `hasIndirections!T == false`.
228229
+/
229-
static typeof(this) create(scope V[] values...) @trusted @nogc
230+
static typeof(this) create(scope V[] values...) @safe @nogc
230231
{
231-
auto ret = RCArray!T(values.length, T.alignof, true, false);
232+
auto ret = typeof(this)(values.length, T.alignof, true, hasElaborateAssign!T);
232233
static if (!hasElaborateAssign!T)
233234
{
234235
()@trusted {
@@ -241,10 +242,10 @@ struct mir_rcarray(T)
241242
import mir.conv: emplaceRef;
242243
auto lhs = ret[];
243244
foreach (i, ref e; values)
244-
lhs[i].emplaceRef(e);
245+
lhs[i] = e;
245246
}
246247
import std.algorithm.mutation: move;
247-
return ret;
248+
return ret.move;
248249
}
249250

250251
private bool initializeImpl()(size_t length, uint alignment, bool deallocate, bool initialize) scope @trusted nothrow @nogc
@@ -283,7 +284,7 @@ struct mir_rcarray(T)
283284

284285
_context.length = length;
285286
_context.counter = deallocate; // 0
286-
if (initialize)
287+
if (initialize ||hasElaborateAssign!T)
287288
{
288289
import mir.conv: uninitializedFillDefault;
289290
import std.traits: Unqual;

0 commit comments

Comments
 (0)