[ox/std] Fix problem with calling Vector::insert on end of list

This commit is contained in:
Gary Talent 2022-03-05 11:37:07 -06:00
parent 191298a4ca
commit e90d6da01b

View File

@ -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;
}