[ox/std] Fix some Vector constexpr problems
This commit is contained in:
parent
5eec9085f8
commit
79b42e1df7
34
deps/ox/src/ox/std/vector.hpp
vendored
34
deps/ox/src/ox/std/vector.hpp
vendored
@ -52,13 +52,15 @@ struct VectorAllocator {
|
|||||||
const std::size_t cap) noexcept {
|
const std::size_t cap) noexcept {
|
||||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||||
// try removing it later
|
// try removing it later
|
||||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
if (!std::is_constant_evaluated()) {
|
||||||
for (auto i = 0u; i < count; ++i) {
|
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||||
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
for (auto i = 0u; i < count; ++i) {
|
||||||
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||||
std::construct_at<T>(dstItem, std::move(*srcItem));
|
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||||
|
std::construct_at<T>(dstItem, std::move(*srcItem));
|
||||||
|
}
|
||||||
|
*items = reinterpret_cast<T*>(m_data.data());
|
||||||
}
|
}
|
||||||
*items = reinterpret_cast<T*>(m_data.data());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,20 +71,24 @@ struct VectorAllocator {
|
|||||||
const std::size_t cap) noexcept {
|
const std::size_t cap) noexcept {
|
||||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||||
// try removing it later
|
// try removing it later
|
||||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
if (!std::is_constant_evaluated()) {
|
||||||
for (std::size_t i = 0; i < count; ++i) {
|
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||||
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
for (std::size_t i = 0; i < count; ++i) {
|
||||||
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||||
*dstItem = std::move(*srcItem);
|
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||||
|
*dstItem = std::move(*srcItem);
|
||||||
|
}
|
||||||
|
*items = reinterpret_cast<T*>(m_data.data());
|
||||||
}
|
}
|
||||||
*items = reinterpret_cast<T*>(m_data.data());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
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
|
// 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()) {
|
||||||
m_allocator.deallocate(items, cap);
|
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