@@ -776,7 +776,35 @@ template <ranges::contiguous_range _Range>
776
776
#endif
777
777
778
778
// [string.view.comparison]
779
+
780
+ #if _LIBCPP_STD_VER >= 20
781
+
782
+ template <class _CharT , class _Traits >
783
+ _LIBCPP_HIDE_FROM_ABI constexpr
784
+ bool operator ==(basic_string_view<_CharT, _Traits> __lhs,
785
+ type_identity_t <basic_string_view<_CharT, _Traits>> __rhs) noexcept {
786
+ if (__lhs.size () != __rhs.size ()) return false ;
787
+ return __lhs.compare (__rhs) == 0 ;
788
+ }
789
+
790
+ template <class _CharT , class _Traits >
791
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator <=>(
792
+ basic_string_view<_CharT, _Traits> __lhs, type_identity_t <basic_string_view<_CharT, _Traits>> __rhs) noexcept {
793
+ if constexpr (requires { typename _Traits::comparison_category; }) {
794
+ // [string.view]/4
795
+ static_assert (
796
+ __comparison_category<typename _Traits::comparison_category>,
797
+ " return type is not a comparison category type" );
798
+ return static_cast <typename _Traits::comparison_category>(__lhs.compare (__rhs) <=> 0 );
799
+ } else {
800
+ return static_cast <weak_ordering>(__lhs.compare (__rhs) <=> 0 );
801
+ }
802
+ }
803
+
804
+ #else
805
+
779
806
// operator ==
807
+
780
808
template <class _CharT , class _Traits >
781
809
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
782
810
bool operator ==(basic_string_view<_CharT, _Traits> __lhs,
@@ -797,8 +825,6 @@ bool operator==(basic_string_view<_CharT, _Traits> __lhs,
797
825
return __lhs.compare (__rhs) == 0 ;
798
826
}
799
827
800
- #if _LIBCPP_STD_VER < 20
801
- // This overload is automatically generated in C++20.
802
828
template <class _CharT , class _Traits , int = 2 >
803
829
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
804
830
bool operator ==(__type_identity_t <basic_string_view<_CharT, _Traits> > __lhs,
@@ -807,41 +833,6 @@ bool operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
807
833
if (__lhs.size () != __rhs.size ()) return false ;
808
834
return __lhs.compare (__rhs) == 0 ;
809
835
}
810
- #endif // _LIBCPP_STD_VER >= 20
811
-
812
- // operator <=>
813
-
814
- #if _LIBCPP_STD_VER >= 20
815
-
816
- template <class _CharT , class _Traits >
817
- _LIBCPP_HIDE_FROM_ABI constexpr auto
818
- operator <=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept {
819
- if constexpr (requires { typename _Traits::comparison_category; }) {
820
- // [string.view]/4
821
- static_assert (
822
- __comparison_category<typename _Traits::comparison_category>,
823
- " return type is not a comparison category type" );
824
- return static_cast <typename _Traits::comparison_category>(__lhs.compare (__rhs) <=> 0 );
825
- } else {
826
- return static_cast <weak_ordering>(__lhs.compare (__rhs) <=> 0 );
827
- }
828
- }
829
-
830
- template <class _CharT , class _Traits , int = 1 >
831
- _LIBCPP_HIDE_FROM_ABI constexpr auto operator <=>(
832
- basic_string_view<_CharT, _Traits> __lhs, type_identity_t <basic_string_view<_CharT, _Traits>> __rhs) noexcept {
833
- if constexpr (requires { typename _Traits::comparison_category; }) {
834
- // [string.view]/4
835
- static_assert (
836
- __comparison_category<typename _Traits::comparison_category>,
837
- " return type is not a comparison category type" );
838
- return static_cast <typename _Traits::comparison_category>(__lhs.compare (__rhs) <=> 0 );
839
- } else {
840
- return static_cast <weak_ordering>(__lhs.compare (__rhs) <=> 0 );
841
- }
842
- }
843
-
844
- #else // _LIBCPP_STD_VER >= 20
845
836
846
837
// operator !=
847
838
template <class _CharT , class _Traits >
0 commit comments