Avoid throwing while relocating Deque contents
This commit is contained in:
parent
32d76fcff1
commit
da28face2c
|
@ -168,10 +168,11 @@ private:
|
|||
if (newSize > max_size()) throw std::bad_alloc();
|
||||
//printf("Growing to %lld (%u-%u mask %u)\n", (long long)newSize, begin, end, mask);
|
||||
T* newArr = (T*)aligned_alloc(std::max(__alignof(T), sizeof(void*)),
|
||||
newSize * sizeof(T)); // SOMEDAY: FastAllocator, exception safety
|
||||
newSize * sizeof(T)); // SOMEDAY: FastAllocator
|
||||
ASSERT(newArr != nullptr);
|
||||
for (int i = begin; i != end; i++) {
|
||||
new (&newArr[i - begin]) T(std::move(arr[i&mask]));
|
||||
new (&newArr[i - begin]) T(std::move_if_noexcept(arr[i & mask]));
|
||||
static_assert(std::is_nothrow_destructible_v<T>);
|
||||
arr[i&mask].~T();
|
||||
}
|
||||
aligned_free(arr);
|
||||
|
|
Loading…
Reference in New Issue