feat(kernel/std): add three way compare for std::basic_string and std::vector

This commit is contained in:
2025-05-10 16:32:54 +00:00
parent dbb5a483e0
commit 9626ec4662
2 changed files with 37 additions and 8 deletions

View File

@ -26,6 +26,7 @@
#include <convert.h>
#include <iterator>
#include <cstddef>
#include <compare>
#include <memory>
#include <ranges>
@ -2264,12 +2265,24 @@ namespace std
return lhs.compare(rhs) == 0;
}
template <class CharT, class Traits, class Alloc>
constexpr auto operator<=>(const std::basic_string<CharT, Traits, Alloc> &lhs, const std::basic_string<CharT, Traits, Alloc> &rhs) noexcept -> decltype(static_cast<weak_ordering>(0 <=> 0))
{
return static_cast<weak_ordering>(lhs.compare(rhs) <=> 0);
}
template <class CharT, class Traits, class Alloc>
constexpr bool operator==(const std::basic_string<CharT, Traits, Alloc> &lhs, const CharT *rhs)
{
return lhs.compare(rhs) == 0;
}
template <class CharT, class Traits, class Alloc>
constexpr auto operator<=>(const std::basic_string<CharT, Traits, Alloc> &lhs, const CharT *rhs) -> decltype(static_cast<weak_ordering>(0 <=> 0))
{
return static_cast<weak_ordering>(lhs.compare(rhs) <=> 0);
}
template <class CharT, class Traits, class Alloc>
std::basic_string<CharT, Traits, Alloc> constexpr operator+(const std::basic_string<CharT, Traits, Alloc> &lhs, const std::basic_string<CharT, Traits, Alloc> &rhs)
{