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