[ox/std] Fix some Vector constexpr problems
This commit is contained in:
parent
5eec9085f8
commit
79b42e1df7
8
deps/ox/src/ox/std/vector.hpp
vendored
8
deps/ox/src/ox/std/vector.hpp
vendored
@ -52,6 +52,7 @@ struct VectorAllocator {
|
||||
const std::size_t cap) noexcept {
|
||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||
// try removing it later
|
||||
if (!std::is_constant_evaluated()) {
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (auto i = 0u; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||
@ -61,6 +62,7 @@ struct VectorAllocator {
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void moveItemsFrom(
|
||||
T **items,
|
||||
@ -69,6 +71,7 @@ struct VectorAllocator {
|
||||
const std::size_t cap) noexcept {
|
||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||
// try removing it later
|
||||
if (!std::is_constant_evaluated()) {
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||
@ -78,13 +81,16 @@ struct VectorAllocator {
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||
if (std::is_constant_evaluated() || (items && static_cast<void*>(items) != static_cast<void*>(m_data.data()))) {
|
||||
if (std::is_constant_evaluated()) {
|
||||
if (items && static_cast<void*>(items) != static_cast<void*>(m_data.data())) {
|
||||
m_allocator.deallocate(items, cap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user