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 = requires (_Tp&& __t, _Up&& __u) { { __t == __u } -> same_as<bool>; }
66 && convertible_to<_Tp, const volatile void*>
67 && convertible_to<_Up, const volatile void*>
68 && (! requires(_Tp&& __t, _Up&& __u)
69 { operator==(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
71 ! requires(_Tp&& __t, _Up&& __u)
72 { std::forward<_Tp>(__t).operator==(std::forward<_Up>(__u)); });
75 template<
typename _Tp,
typename _Up>
76 concept __less_builtin_ptr_cmp
77 = requires (_Tp&& __t, _Up&& __u) { { __t < __u } -> same_as<bool>; }
78 && convertible_to<_Tp, const volatile void*>
79 && convertible_to<_Up, const volatile void*>
80 && (! requires(_Tp&& __t, _Up&& __u)
81 { operator<(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
82 && ! requires(_Tp&& __t, _Up&& __u)
83 { std::forward<_Tp>(__t).operator<(std::forward<_Up>(__u)); });
91 template<
typename _Tp,
typename _Up>
92 requires equality_comparable_with<_Tp, _Up>
93 || __detail::__eq_builtin_ptr_cmp<_Tp, _Up>
95 operator()(_Tp&& __t, _Up&& __u)
const
96 noexcept(noexcept(std::declval<_Tp>() == std::declval<_Up>()))
97 {
return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
99 using is_transparent = __is_transparent;
105 template<
typename _Tp,
typename _Up>
106 requires equality_comparable_with<_Tp, _Up>
107 || __detail::__eq_builtin_ptr_cmp<_Tp, _Up>
109 operator()(_Tp&& __t, _Up&& __u)
const
110 noexcept(noexcept(std::declval<_Up>() == std::declval<_Tp>()))
111 {
return !equal_to{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
113 using is_transparent = __is_transparent;
119 template<
typename _Tp,
typename _Up>
120 requires totally_ordered_with<_Tp, _Up>
121 || __detail::__less_builtin_ptr_cmp<_Tp, _Up>
123 operator()(_Tp&& __t, _Up&& __u)
const
124 noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>()))
126 if constexpr (__detail::__less_builtin_ptr_cmp<_Tp, _Up>)
128 #ifdef __cpp_lib_is_constant_evaluated
129 if (std::is_constant_evaluated())
132 auto __x =
reinterpret_cast<__UINTPTR_TYPE__
>(
133 static_cast<const volatile void*
>(std::forward<_Tp>(__t)));
134 auto __y =
reinterpret_cast<__UINTPTR_TYPE__
>(
135 static_cast<const volatile void*
>(std::forward<_Up>(__u)));
139 return std::forward<_Tp>(__t) < std::forward<_Up>(__u);
142 using is_transparent = __is_transparent;
148 template<
typename _Tp,
typename _Up>
149 requires totally_ordered_with<_Tp, _Up>
150 || __detail::__less_builtin_ptr_cmp<_Up, _Tp>
152 operator()(_Tp&& __t, _Up&& __u)
const
153 noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>()))
154 {
return less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); }
156 using is_transparent = __is_transparent;
162 template<
typename _Tp,
typename _Up>
163 requires totally_ordered_with<_Tp, _Up>
164 || __detail::__less_builtin_ptr_cmp<_Tp, _Up>
166 operator()(_Tp&& __t, _Up&& __u)
const
167 noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>()))
168 {
return !less{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
170 using is_transparent = __is_transparent;
176 template<
typename _Tp,
typename _Up>
177 requires totally_ordered_with<_Tp, _Up>
178 || __detail::__less_builtin_ptr_cmp<_Up, _Tp>
180 operator()(_Tp&& __t, _Up&& __u)
const
181 noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>()))
182 {
return !less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); }
184 using is_transparent = __is_transparent;
188 #endif // library concepts
189 _GLIBCXX_END_NAMESPACE_VERSION
192 #endif // _RANGE_CMP_H