[ox/std] Fix problem with calling Vector::insert on end of list
This commit is contained in:
parent
191298a4ca
commit
e90d6da01b
10
deps/ox/src/ox/std/vector.hpp
vendored
10
deps/ox/src/ox/std/vector.hpp
vendored
@ -571,10 +571,14 @@ constexpr void Vector<T, SmallVectorSize>::insert(std::size_t pos, const T &val)
|
||||
if (m_size == m_cap) {
|
||||
expandCap(m_cap ? m_cap * 2 : initialSize);
|
||||
}
|
||||
for (auto i = m_size; i > pos; --i) {
|
||||
new (&m_items[i]) T(std::move(m_items[i - 1]));
|
||||
if (pos < m_size) {
|
||||
for (auto i = m_size; i > pos; --i) {
|
||||
new(&m_items[i]) T(std::move(m_items[i - 1]));
|
||||
}
|
||||
m_items[pos] = val;
|
||||
} else {
|
||||
new(&m_items[pos]) T(val);
|
||||
}
|
||||
m_items[pos] = val;
|
||||
++m_size;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user