diff --git a/src/ox/std/ignore.hpp b/src/ox/std/ignore.hpp index 52fc42541..5dcaa5c9d 100644 --- a/src/ox/std/ignore.hpp +++ b/src/ox/std/ignore.hpp @@ -16,7 +16,7 @@ namespace std { -inline constexpr struct ignore_t { +inline constexpr struct { constexpr void operator=(auto&&) const noexcept {} } ignore; diff --git a/src/ox/std/memory.hpp b/src/ox/std/memory.hpp index f5f3f9fb7..f145d9a9e 100644 --- a/src/ox/std/memory.hpp +++ b/src/ox/std/memory.hpp @@ -213,8 +213,7 @@ class UniquePtr { return m_t; } - template - constexpr void reset(UniquePtr &&other = UniquePtr()) { + constexpr void reset(UniquePtr &&other = UniquePtr()) { auto t = m_t; m_t = other.release(); Deleter()(t); diff --git a/src/ox/std/span.hpp b/src/ox/std/span.hpp index 381e83eb9..871dd8829 100644 --- a/src/ox/std/span.hpp +++ b/src/ox/std/span.hpp @@ -163,24 +163,6 @@ class Span { return *this; } - constexpr Span operator++(int) noexcept { - ++m_items; - --m_size; - if (!m_size) [[unlikely]] { - m_items = nullptr; - } - return *this; - } - - constexpr Span operator++() noexcept { - ++m_items; - --m_size; - if (!m_size) [[unlikely]] { - m_items = nullptr; - } - return *this; - } - [[nodiscard]] constexpr auto data() const noexcept { return m_items; diff --git a/src/ox/std/string.hpp b/src/ox/std/string.hpp index d31f58be3..8a1cb7d00 100644 --- a/src/ox/std/string.hpp +++ b/src/ox/std/string.hpp @@ -139,7 +139,7 @@ class BasicString { constexpr BasicString &operator+=(Integer_c auto i) noexcept; - constexpr BasicString &operator+=(StringViewCR src) noexcept; + constexpr BasicString &operator+=(StringView src) noexcept; constexpr BasicString &operator+=(BasicString const&src) noexcept; @@ -185,7 +185,7 @@ class BasicString { return {}; } - constexpr Error append(StringViewCR sv) noexcept { + constexpr Error append(ox::StringView sv) noexcept { return append(sv.data(), sv.size()); } @@ -376,7 +376,7 @@ constexpr BasicString &BasicString::operat } template -constexpr BasicString &BasicString::operator+=(StringViewCR s) noexcept { +constexpr BasicString &BasicString::operator+=(StringView s) noexcept { std::size_t strLen = s.bytes(); std::ignore = append(s.data(), strLen); return *this; @@ -456,7 +456,7 @@ constexpr bool BasicString::operator==(const char *other) con template constexpr bool BasicString::operator==(OxString_c auto const&other) const noexcept { - return StringView(*this) == StringView(other); + return ox::StringView(*this) == ox::StringView(other); } template @@ -548,28 +548,28 @@ using StringCR = String const&; [[nodiscard]] -constexpr String toString(StringViewCR sv) noexcept { +constexpr ox::String toString(ox::StringViewCR sv) noexcept { return ox::String(sv); } template [[nodiscard]] -constexpr auto sizeOf(BasicString const*) noexcept { +constexpr auto sizeOf(const ox::BasicString*) noexcept { VectorMemMap v{.smallVecSize = SmallStringSize_v}; return sizeOf(&v); } template [[nodiscard]] -constexpr auto alignOf(BasicString const&) noexcept { +constexpr auto alignOf(const ox::BasicString&) noexcept { VectorMemMap v{.smallVecSize = SmallStringSize_v}; return alignOf(&v); } template -struct MaybeView> { - using type = StringView; +struct MaybeView> { + using type = ox::StringView; }; } diff --git a/src/ox/std/strops.hpp b/src/ox/std/strops.hpp index 86251f447..b2f3ec99f 100644 --- a/src/ox/std/strops.hpp +++ b/src/ox/std/strops.hpp @@ -21,7 +21,7 @@ OX_CLANG_NOWARN_BEGIN(-Wunsafe-buffer-usage) namespace ox { [[nodiscard]] -constexpr StringView substr(StringViewCR str, std::size_t const pos) noexcept { +constexpr ox::StringView substr(ox::StringView const&str, std::size_t pos) noexcept { if (str.size() >= pos) { return {&str[pos], str.size() - pos}; } @@ -29,23 +29,13 @@ constexpr StringView substr(StringViewCR str, std::size_t const pos) noexcept { } [[nodiscard]] -constexpr StringView substr(StringViewCR str, std::size_t const start, std::size_t const end) noexcept { +constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std::size_t end) noexcept { if (str.size() >= start && end >= start) { return {&str[start], end - start}; } return {}; } -[[nodiscard]] -constexpr bool beginsWith(StringViewCR base, char const beginning) noexcept { - return base.size() && base[0] == beginning; -} - -[[nodiscard]] -constexpr bool endsWith(StringViewCR base, char const ending) noexcept { - return base.size() && base[base.size() - 1] == ending; -} - [[nodiscard]] constexpr bool beginsWith(StringViewCR base, StringViewCR beginning) noexcept { const auto beginningLen = ox::min(beginning.size(), base.size()); @@ -59,7 +49,7 @@ constexpr bool endsWith(StringViewCR base, StringViewCR ending) noexcept { } [[nodiscard]] -constexpr std::size_t find(StringViewCR str, char const search) noexcept { +constexpr std::size_t find(StringViewCR str, char search) noexcept { std::size_t i = 0; for (; i < str.size(); ++i) { if (str[i] == search) { @@ -82,7 +72,7 @@ constexpr std::size_t find(StringViewCR str, StringViewCR search) noexcept { template [[nodiscard]] -constexpr ox::Vector split(StringViewCR str, char const del) noexcept { +constexpr ox::Vector split(StringViewCR str, char del) noexcept { ox::Vector out; constexpr auto nextSeg = [](StringViewCR current, char del) { return substr(current, find(current, del) + 1); @@ -115,7 +105,7 @@ constexpr ox::Vector split(StringViewCR str, StringView } [[nodiscard]] -constexpr ox::Result lastIndexOf(ox::StringViewCR str, int const character) noexcept { +constexpr ox::Result lastIndexOf(ox::StringViewCR str, int character) noexcept { ox::Result retval = ox::Error(1, "Character not found"); for (auto i = static_cast(str.bytes() - 1); i >= 0; --i) { if (str[static_cast(i)] == character) { diff --git a/src/ox/std/vector.hpp b/src/ox/std/vector.hpp index aa5706215..faab0650f 100644 --- a/src/ox/std/vector.hpp +++ b/src/ox/std/vector.hpp @@ -87,9 +87,7 @@ struct VectorAllocator { 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()) { - if (items) { - Allocator{}.deallocate(items, cap); - } + Allocator{}.deallocate(items, cap); } else { if (items && static_cast(items) != static_cast(m_data.data())) { Allocator{}.deallocate(items, cap);