libstdc++: ranges_cmp.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#ifndef _RANGES_CMP_H
31#define _RANGES_CMP_H 1
32
33#if __cplusplus > 201703L
36
37namespace std _GLIBCXX_VISIBILITY(default)
38{
39_GLIBCXX_BEGIN_NAMESPACE_VERSION
40
41 struct __is_transparent;
42
43
44
45
46
48 {
49 template<typename _Tp>
50 [[nodiscard]]
51 constexpr _Tp&&
52 operator()(_Tp&& __t) const noexcept
53 { return std::forward<_Tp>(__t); }
54
55 using is_transparent = __is_transparent;
56 };
57
58#ifdef __glibcxx_ranges
59namespace ranges
60{
61 namespace __detail
62 {
63
64
65
66 template<typename _Tp, typename _Up>
67 concept __less_builtin_ptr_cmp
68 = requires (_Tp&& __t, _Up&& __u) { { __t < __u } -> same_as; }
69 && convertible_to<_Tp, const volatile void*>
70 && convertible_to<_Up, const volatile void*>
71 && (! requires(_Tp&& __t, _Up&& __u)
72 { operator<(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
73 && ! requires(_Tp&& __t, _Up&& __u)
74 { std::forward<_Tp>(__t).operator<(std::forward<_Up>(__u)); });
75 }
76
77
78
79
80
81
82
84 {
85 template<typename _Tp, typename _Up>
86 requires equality_comparable_with<_Tp, _Up>
87 constexpr bool
88 operator()(_Tp&& __t, _Up&& __u) const
89 noexcept(noexcept(std::declval<_Tp>() == std::declval<_Up>()))
90 { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
91
92 using is_transparent = __is_transparent;
93 };
94
95
97 {
98 template<typename _Tp, typename _Up>
99 requires equality_comparable_with<_Tp, _Up>
100 constexpr bool
101 operator()(_Tp&& __t, _Up&& __u) const
102 noexcept(noexcept(std::declval<_Up>() == std::declval<_Tp>()))
103 { return {}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
104
105 using is_transparent = __is_transparent;
106 };
107
108
110 {
111 template<typename _Tp, typename _Up>
112 requires totally_ordered_with<_Tp, _Up>
113 constexpr bool
114 operator()(_Tp&& __t, _Up&& __u) const
115 noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>()))
116 {
117 if constexpr (__detail::__less_builtin_ptr_cmp<_Tp, _Up>)
118 {
119 if (std::__is_constant_evaluated())
120 return __t < __u;
121
122 auto __x = reinterpret_cast<__UINTPTR_TYPE__>(
123 static_cast<const volatile void*>(std::forward<_Tp>(__t)));
124 auto __y = reinterpret_cast<__UINTPTR_TYPE__>(
125 static_cast<const volatile void*>(std::forward<_Up>(__u)));
126 return __x < __y;
127 }
128 else
129 return std::forward<_Tp>(__t) < std::forward<_Up>(__u);
130 }
131
132 using is_transparent = __is_transparent;
133 };
134
135
137 {
138 template<typename _Tp, typename _Up>
139 requires totally_ordered_with<_Tp, _Up>
140 constexpr bool
141 operator()(_Tp&& __t, _Up&& __u) const
142 noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>()))
143 { return less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); }
144
145 using is_transparent = __is_transparent;
146 };
147
148
150 {
151 template<typename _Tp, typename _Up>
152 requires totally_ordered_with<_Tp, _Up>
153 constexpr bool
154 operator()(_Tp&& __t, _Up&& __u) const
155 noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>()))
156 { return {}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); }
157
158 using is_transparent = __is_transparent;
159 };
160
161
163 {
164 template<typename _Tp, typename _Up>
165 requires totally_ordered_with<_Tp, _Up>
166 constexpr bool
167 operator()(_Tp&& __t, _Up&& __u) const
168 noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>()))
169 { return {}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); }
170
171 using is_transparent = __is_transparent;
172 };
173
174}
175#endif
176_GLIBCXX_END_NAMESPACE_VERSION
177}
178#endif
179#endif
ISO C++ entities toplevel namespace is std.
[func.identity] The identity function.
ranges::equal_to function object type.
ranges::not_equal_to function object type.
ranges::less function object type.
ranges::greater function object type.
ranges::greater_equal function object type.
ranges::less_equal function object type.