fix error in insert

This commit is contained in:
2024-02-26 00:05:09 +00:00
parent 78abd9ef99
commit 8b1e8e6d34
2 changed files with 5 additions and 2 deletions

View File

@ -368,7 +368,7 @@ class vector {
raw_end = raw_beg + current_length;
allocated_length = new_allocated_length;
}
for (T *i = raw_end - 1; i != pos.raw_pointer; --i) {
for (T *i = raw_end; i != pos.raw_pointer; --i) {
std::allocator_traits<decltype(alloc)>::construct(alloc, i, std::move(*(i - 1)));
std::allocator_traits<decltype(alloc)>::destroy(alloc, i - 1);
}
@ -398,7 +398,7 @@ class vector {
raw_end = raw_beg + current_length;
allocated_length = new_allocated_length;
}
for (T *i = raw_end - 1; i != raw_beg + ind; --i) {
for (T *i = raw_end; i != raw_beg + ind; --i) {
alloc.construct(i, std::move(*(i - 1)));
alloc.destroy(i - 1);
}