diff --git a/src/ox/std/vector.hpp b/src/ox/std/vector.hpp index b03a9c996..a00a30732 100644 --- a/src/ox/std/vector.hpp +++ b/src/ox/std/vector.hpp @@ -26,6 +26,8 @@ namespace detail { template struct VectorAllocator { + static_assert(sizeof(AllocAlias) == sizeof(T)); + static_assert(alignof(AllocAlias) == alignof(T)); private: ox::Array, Size> m_data = {}; Allocator m_allocator; @@ -46,11 +48,11 @@ struct VectorAllocator { constexpr void moveConstructItemsFrom(T **items, VectorAllocator *src, const std::size_t count, 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 (cap <= Size && count <= Size) { - const auto dstItems = reinterpret_cast(m_data.data()); - const auto srcItems = reinterpret_cast(src->m_data.data()); + if (cap <= m_data.size() && count <= m_data.size()) { for (auto i = 0u; i < count; ++i) { - std::construct_at(&dstItems[i], std::move(srcItems[i])); + const auto dstItem = reinterpret_cast(&m_data[i]); + const auto srcItem = reinterpret_cast(&src->m_data[i]); + std::construct_at(dstItem, std::move(*srcItem)); } *items = reinterpret_cast(m_data.data()); } @@ -59,11 +61,11 @@ struct VectorAllocator { constexpr void moveItemsFrom(T **items, VectorAllocator *src, const std::size_t count, 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 (cap <= Size && count <= Size) { - const auto dstItems = reinterpret_cast(m_data.data()); - const auto srcItems = reinterpret_cast(src->m_data.data()); + if (cap <= m_data.size() && count <= m_data.size()) { for (std::size_t i = 0; i < count; ++i) { - dstItems[i] = std::move(srcItems[i]); + const auto dstItem = reinterpret_cast(&m_data[i]); + const auto srcItem = reinterpret_cast(&src->m_data[i]); + *dstItem = std::move(*srcItem); } *items = reinterpret_cast(m_data.data()); }