Fix moveEmplace for static arrays

This commit is contained in:
2017-11-01 14:27:39 +01:00
parent 12fb9ff9f6
commit e06cc5a071
2 changed files with 66 additions and 22 deletions

View File

@ -514,7 +514,6 @@ struct Array(T)
{
allocator.deallocate(buf);
}
const T* end = this.data + this.length_;
for (T* src = this.data, dest = cast(T*) buf; src != end; ++src, ++dest)
{
moveEmplace(*src, *dest);
@ -640,6 +639,11 @@ struct Array(T)
assert(v.removeBack(3) == 0);
}
private @property inout(T)* end() inout
{
return this.data + this.length_;
}
/**
* Remove all elements beloning to $(D_PARAM r).
*
@ -660,12 +664,10 @@ struct Array(T)
}
body
{
auto end = this.data + this.length;
auto source = Range(this, r.end, end);
auto target = Range(this, r.begin, end);
for (; !source.empty; source.popFront(), target.popFront())
auto target = r.begin;
for (auto source = r.end; source != end; ++source, ++target)
{
move(source.front, target.front);
move(*source, *target);
}
length = length - r.length;
return Range(this, r.begin, this.data + length);
@ -696,7 +698,7 @@ struct Array(T)
if (isImplicitlyConvertible!(R, T))
{
reserve(this.length + 1);
moveEmplace(el, *(this.data + this.length_));
moveEmplace(el, *end);
++this.length_;
}