diff --git a/deps/ox/src/ox/std/string.cpp b/deps/ox/src/ox/std/string.cpp index df0bcd1e..40128c5f 100644 --- a/deps/ox/src/ox/std/string.cpp +++ b/deps/ox/src/ox/std/string.cpp @@ -10,6 +10,6 @@ namespace ox { -template class BasicString<0>; +template class BasicString<8>; } diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index 56d96f6a..17bff72c 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -20,7 +20,7 @@ namespace ox { -template +template class BasicString { private: Vector m_buff; @@ -208,9 +208,11 @@ constexpr BasicString::BasicString() noexcept { } template -constexpr BasicString::BasicString(std::size_t cap) noexcept { - m_buff.resize(cap + 1); - m_buff[0] = 0; +constexpr BasicString::BasicString(std::size_t cap) noexcept: m_buff(cap + 1) { + // GCC complains if you don't do this pretty unnecessary size check + if (m_buff.size()) { + m_buff[0] = 0; + } } template @@ -247,7 +249,7 @@ constexpr BasicString::BasicString(const BasicString &other) no template constexpr BasicString::BasicString(BasicString &&other) noexcept { - m_buff = move(other.m_buff); + m_buff = std::move(other.m_buff); } template @@ -499,8 +501,8 @@ constexpr std::size_t BasicString::len() const noexcept { return length; } -extern template class BasicString<0>; +extern template class BasicString<8>; -using String = BasicString<0>; +using String = BasicString<8>; } diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index 580d50f0..9d02234f 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -21,7 +21,7 @@ namespace ox { namespace detail { -template +template struct SmallVector { private: std::allocator m_allocator; @@ -45,18 +45,20 @@ struct SmallVector { const auto dstItems = reinterpret_cast(m_data); const auto srcItems = reinterpret_cast(src.m_data); for (auto i = 0u; i < count; ++i) { - new (&dstItems[i]) T(move(srcItems[i])); + new (&dstItems[i]) T(std::move(srcItems[i])); } *items = reinterpret_cast(m_data); } } constexpr void moveItemsFrom(T **items, SmallVector &src, const std::size_t count, const std::size_t cap) noexcept { - if (cap <= Size) { + // 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); const auto srcItems = reinterpret_cast(src.m_data); - for (auto i = 0u; i < count; ++i) { - dstItems[i] = move(srcItems[i]); + for (std::size_t i = 0; i < count; ++i) { + dstItems[i] = std::move(srcItems[i]); } *items = reinterpret_cast(m_data); } @@ -101,7 +103,7 @@ struct SmallVector { } -template +template class Vector: detail::SmallVector { public: @@ -603,12 +605,9 @@ constexpr void Vector::expandCap(std::size_t cap) { m_cap = cap; this->allocate(&m_items, cap); if (oldItems) { // move over old items - const auto itRange = cap > m_size ? m_size : cap; - for (std::size_t i = 0; i < itRange; i++) { - new (&m_items[i]) T(move(oldItems[i])); - } - for (std::size_t i = itRange; i < m_cap; i++) { - new (&m_items[i]) T; + const auto itRange = ox::min(cap, m_size); + for (std::size_t i = 0; i < itRange; ++i) { + new (&m_items[i]) T(std::move(oldItems[i])); } this->deallocate(oldItems, m_cap); }