31 #define _RANGE_CMP_H 1
33 #if __cplusplus > 201703L
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
41 struct __is_transparent;
49 template<
typename _Tp>
51 operator()(_Tp&& __t)
const noexcept
52 {
return std::forward<_Tp>(__t); }
54 using is_transparent = __is_transparent;
57 #ifdef __cpp_lib_concepts
63 template<
typename _Tp,
typename _Up>
64 concept __eq_builtin_ptr_cmp
65 = convertible_to<_Tp, const volatile void*>
66 && convertible_to<_Up, const volatile void*>
67 && (! requires(_Tp&& __t, _Up&& __u)
68 { operator==(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
70 ! requires(_Tp&& __t, _Up&& __u)
71 { std::forward<_Tp>(__t).operator==(std::forward<_Up>(__u)); });
74 template<
typename _Tp,
typename _Up>
75 concept __less_builtin_ptr_cmp
76 = convertible_to<_Tp, const volatile void*>
77 && convertible_to<_Up, const volatile void*>
78 && (! requires(_Tp&& __t, _Up&& __u)
79 { operator<(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
80 && ! requires(_Tp&& __t, _Up&& __u)
81 { std::forward<_Tp>(__t).operator<(std::forward<_Up>(__u)); });
89 template<
typename _Tp,
typename _Up>
90 requires equality_comparable_with<_Tp, _Up>
91 || __detail::__eq_builtin_ptr_cmp<_Tp, _Up>
93 operator()(_Tp&& __t, _Up&& __u)
const
94 noexcept(noexcept(std::declval<_Tp>() == std::declval<_Up>()))
95 {
return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
97 using is_transparent = __is_transparent;
103 template<
typename _Tp,
typename _Up>
104 requires equality_comparable_with<_Tp, _Up>
105 || __detail::__eq_builtin_ptr_cmp<_Tp, _Up>
107 operator()(_Tp&& __t, _Up&& __u)
const
108 noexcept(noexcept(std::declval<_Up>() == std::declval<_Tp>()))
109 {
return !equal_to{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
111 using is_transparent = __is_transparent;
117 template<
typename _Tp,
typename _Up>
118 requires totally_ordered_with<_Tp, _Up>
119 || __detail::__less_builtin_ptr_cmp<_Tp, _Up>
121 operator()(_Tp&& __t, _Up&& __u)
const
122 noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>()))
124 if constexpr (__detail::__less_builtin_ptr_cmp<_Tp, _Up>)
126 #ifdef __cpp_lib_is_constant_evaluated
127 if (std::is_constant_evaluated())
130 auto __x =
reinterpret_cast<__UINTPTR_TYPE__
>(
131 static_cast<const volatile void*
>(std::forward<_Tp>(__t)));
132 auto __y =
reinterpret_cast<__UINTPTR_TYPE__
>(
133 static_cast<const volatile void*
>(std::forward<_Up>(__u)));
137 return std::forward<_Tp>(__t) < std::forward<_Up>(__u);
140 using is_transparent = __is_transparent;
146 template<
typename _Tp,
typename _Up>
147 requires totally_ordered_with<_Tp, _Up>
148 || __detail::__less_builtin_ptr_cmp<_Up, _Tp>
150 operator()(_Tp&& __t, _Up&& __u)
const
151 noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>()))
152 {
return less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); }
154 using is_transparent = __is_transparent;
160 template<
typename _Tp,
typename _Up>
161 requires totally_ordered_with<_Tp, _Up>
162 || __detail::__less_builtin_ptr_cmp<_Tp, _Up>
164 operator()(_Tp&& __t, _Up&& __u)
const
165 noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>()))
166 {
return !less{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
168 using is_transparent = __is_transparent;
174 template<
typename _Tp,
typename _Up>
175 requires totally_ordered_with<_Tp, _Up>
176 || __detail::__less_builtin_ptr_cmp<_Up, _Tp>
178 operator()(_Tp&& __t, _Up&& __u)
const
179 noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>()))
180 {
return !less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); }
182 using is_transparent = __is_transparent;
186 #endif // library concepts
187 _GLIBCXX_END_NAMESPACE_VERSION
190 #endif // _RANGE_CMP_H