Replace std::lexicographical_compare_three_way with custom code

On latest MacOS this function is still not implemented
This commit is contained in:
Maxime Coste 2023-11-03 13:08:26 +11:00
parent 154a393c7b
commit c889c0329c

View File

@ -343,8 +343,15 @@ inline bool operator==(const StringView& lhs, const StringView& rhs)
inline auto operator<=>(const StringView& lhs, const StringView& rhs) inline auto operator<=>(const StringView& lhs, const StringView& rhs)
{ {
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), auto lit = lhs.begin(), lend = lhs.end(), rit = rhs.begin(), rend = rhs.end();
rhs.begin(), rhs.end()); while (lit != lend and rit != rend) {
if (auto cmp = *lit++ <=> *rit++; cmp != 0)
return cmp;
}
if (lit == lend and rit == rend)
return std::strong_ordering::equal;
return lit == lend ? std::strong_ordering::less : std::strong_ordering::greater;
} }
inline String operator"" _str(const char* str, size_t) inline String operator"" _str(const char* str, size_t)