[ox] Fix compiler warnings
This commit is contained in:
21
deps/ox/src/ox/std/vector.hpp
vendored
21
deps/ox/src/ox/std/vector.hpp
vendored
@@ -337,6 +337,8 @@ class Vector: detail::VectorAllocator<T, SmallVectorSize> {
|
||||
[[nodiscard]]
|
||||
constexpr bool contains(const T&) const;
|
||||
|
||||
constexpr void insert(std::size_t pos, std::size_t cnt, const T &val);
|
||||
|
||||
constexpr void insert(std::size_t pos, const T &val);
|
||||
|
||||
template<typename... Args>
|
||||
@@ -564,6 +566,25 @@ constexpr bool Vector<T, SmallVectorSize>::contains(const T &v) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize>
|
||||
constexpr void Vector<T, SmallVectorSize>::insert(std::size_t pos, std::size_t cnt, const T &val) {
|
||||
// TODO: insert should ideally have its own expandCap
|
||||
if (m_size + cnt > m_cap) {
|
||||
expandCap(m_cap ? m_size + cnt : initialSize);
|
||||
}
|
||||
if (pos < m_size) {
|
||||
for (auto i = m_size + cnt - 1; i > pos; --i) {
|
||||
std::construct_at(&m_items[i], std::move(m_items[i - cnt]));
|
||||
}
|
||||
m_items[pos] = val;
|
||||
} else {
|
||||
for (auto i = 0u; i < cnt; ++i) {
|
||||
std::construct_at(&m_items[pos + i], val);
|
||||
}
|
||||
}
|
||||
++m_size;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize>
|
||||
constexpr void Vector<T, SmallVectorSize>::insert(std::size_t pos, const T &val) {
|
||||
// TODO: insert should ideally have its own expandCap
|
||||
|
||||
Reference in New Issue
Block a user