util/AllocatedArray: copy constructor copies "nulled" state
This commit is contained in:
parent
2cc1dd28cd
commit
aee861c009
@ -62,11 +62,13 @@ public:
|
|||||||
assert(size() == 0 || buffer.data != nullptr);
|
assert(size() == 0 || buffer.data != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit AllocatedArray(const AllocatedArray &other) noexcept
|
explicit AllocatedArray(const AllocatedArray &other) noexcept {
|
||||||
:buffer{new T[other.buffer.size], other.buffer.size} {
|
|
||||||
assert(size() == 0 || buffer.data != nullptr);
|
|
||||||
assert(other.size() == 0 || other.buffer.data != nullptr);
|
assert(other.size() == 0 || other.buffer.data != nullptr);
|
||||||
|
|
||||||
|
if (other == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
buffer = {new T[other.buffer.size], other.buffer.size};
|
||||||
std::copy_n(other.buffer.data, buffer.size, buffer.data);
|
std::copy_n(other.buffer.data, buffer.size, buffer.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user