diff options
| author | Maxime Coste <mawww@kakoune.org> | 2023-11-03 13:08:26 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2023-11-03 13:08:26 +1100 |
| commit | c889c0329caad7890480c3e3103b49830b8cb7e3 (patch) | |
| tree | 5951f357488bd9292dca6c56be9d1fa9abe4051d /src/string.hh | |
| parent | 154a393c7bff268d62233610ccf37c80a3b9b104 (diff) | |
Replace std::lexicographical_compare_three_way with custom code
On latest MacOS this function is still not implemented
Diffstat (limited to 'src/string.hh')
| -rw-r--r-- | src/string.hh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/string.hh b/src/string.hh index ec199d4c..b6b313a1 100644 --- a/src/string.hh +++ b/src/string.hh @@ -343,8 +343,15 @@ inline bool 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(), - rhs.begin(), rhs.end()); + auto lit = lhs.begin(), lend = lhs.end(), rit = rhs.begin(), rend = 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) |
