Skip to content

Commit d90c940

Browse files
committed
added and removed more operators
1 parent 1418c12 commit d90c940

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

stl/inc/xstring

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ _NODISCARD constexpr bool operator==(
16841684
return _Lhs._Equal(_Rhs);
16851685
}
16861686

1687-
1687+
#if !_HAS_CXX20
16881688
// FUNCTION TEMPLATES operator!= FOR basic_string_view
16891689
template <class _Elem, class _Traits>
16901690
_NODISCARD constexpr bool operator!=(
@@ -1783,7 +1783,37 @@ _NODISCARD constexpr bool operator>=(
17831783
const basic_string_view<_Elem, _Traits> _Lhs, const _Identity_t<basic_string_view<_Elem, _Traits>> _Rhs) noexcept {
17841784
return _Lhs.compare(_Rhs) >= 0;
17851785
}
1786+
#endif // !_HAS_CXX20
1787+
1788+
#if _HAS_CXX20
1789+
template <class _Traits, class = void>
1790+
struct _Get_comparison_category {
1791+
using comparison_category = weak_ordering;
1792+
};
1793+
1794+
template <class _Traits>
1795+
struct _Get_comparison_category<_Traits, void_t<typename _Traits::comparison_category>> {
1796+
using comparison_category = typename _Traits::comparison_category;
1797+
};
1798+
1799+
template <class _Elem, class _Traits>
1800+
_NODISCARD constexpr typename _Get_comparison_category<_Traits>::comparison_category operator<=>(
1801+
const basic_string_view<_Elem, _Traits>& _Lhs, const basic_string_view<_Elem, _Traits>& _Rhs) noexcept {
1802+
return static_cast<typename _Get_comparison_category<_Traits>::comparison_category>(_Lhs.compare(_Rhs) <=> 0);
1803+
}
17861804

1805+
template <class _Elem, class _Traits, int = 1> // TRANSITION, VSO-409326
1806+
_NODISCARD constexpr typename _Get_comparison_category<_Traits>::comparison_category operator<=>(
1807+
const _Identity_t<basic_string_view<_Elem, _Traits>> _Lhs, const basic_string_view<_Elem, _Traits> _Rhs) noexcept {
1808+
return static_cast<typename _Get_comparison_category<_Traits>::comparison_category>(_Lhs.compare(_Rhs) <=> 0);
1809+
}
1810+
1811+
template <class _Elem, class _Traits, int = 2> // TRANSITION, VSO-409326
1812+
_NODISCARD constexpr typename _Get_comparison_category<_Traits>::comparison_category operator<=>(
1813+
const basic_string_view<_Elem, _Traits> _Lhs, const _Identity_t<basic_string_view<_Elem, _Traits>> _Rhs) noexcept {
1814+
return static_cast<typename _Get_comparison_category<_Traits>::comparison_category>(_Lhs.compare(_Rhs) <=> 0);
1815+
}
1816+
#endif // _HAS_CXX20
17871817

17881818
// TYPEDEFS FOR basic_string_view
17891819
using string_view = basic_string_view<char>;
@@ -4619,19 +4649,12 @@ _NODISCARD bool operator>=(const basic_string<_Elem, _Traits, _Alloc>& _Left, _I
46194649
#endif // !_HAS_CXX20
46204650

46214651
#if _HAS_CXX20
4622-
template <class _Traits, class = void>
4623-
struct _Get_comparison_category {
4624-
using comparison_category = weak_ordering;
4625-
};
4626-
template <class _Traits>
4627-
struct _Get_comparison_category<_Traits, void_t<typename _Traits::comparison_category>> {
4628-
using comparison_category = typename _Traits::comparison_category;
4629-
};
46304652
template <class _Elem, class _Traits, class _Alloc>
46314653
_NODISCARD typename _Get_comparison_category<_Traits>::comparison_category operator<=>(
46324654
const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) noexcept {
46334655
return static_cast<typename _Get_comparison_category<_Traits>::comparison_category>(_Left.compare(_Right) <=> 0);
46344656
}
4657+
46354658
template <class _Elem, class _Traits, class _Alloc>
46364659
_NODISCARD typename _Get_comparison_category<_Traits>::comparison_category operator<=>(
46374660
const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem* _Right) {

0 commit comments

Comments
 (0)