source: Daodan/MSYS2/mingw32/include/c++/11.2.0/bits/predefined_ops.h

Last change on this file was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 9.9 KB
Line 
1// Default predicates for internal use -*- C++ -*-
2
3// Copyright (C) 2013-2021 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file predefined_ops.h
26 * This is an internal header file, included by other library headers.
27 * You should not attempt to use it directly. @headername{algorithm}
28 */
29
30#ifndef _GLIBCXX_PREDEFINED_OPS_H
31#define _GLIBCXX_PREDEFINED_OPS_H 1
32
33#include <bits/move.h>
34
35namespace __gnu_cxx
36{
37namespace __ops
38{
39 struct _Iter_less_iter
40 {
41 template<typename _Iterator1, typename _Iterator2>
42 _GLIBCXX14_CONSTEXPR
43 bool
44 operator()(_Iterator1 __it1, _Iterator2 __it2) const
45 { return *__it1 < *__it2; }
46 };
47
48 _GLIBCXX14_CONSTEXPR
49 inline _Iter_less_iter
50 __iter_less_iter()
51 { return _Iter_less_iter(); }
52
53 struct _Iter_less_val
54 {
55#if __cplusplus >= 201103L
56 constexpr _Iter_less_val() = default;
57#else
58 _Iter_less_val() { }
59#endif
60
61 _GLIBCXX20_CONSTEXPR
62 explicit
63 _Iter_less_val(_Iter_less_iter) { }
64
65 template<typename _Iterator, typename _Value>
66 _GLIBCXX20_CONSTEXPR
67 bool
68 operator()(_Iterator __it, _Value& __val) const
69 { return *__it < __val; }
70 };
71
72 _GLIBCXX20_CONSTEXPR
73 inline _Iter_less_val
74 __iter_less_val()
75 { return _Iter_less_val(); }
76
77 _GLIBCXX20_CONSTEXPR
78 inline _Iter_less_val
79 __iter_comp_val(_Iter_less_iter)
80 { return _Iter_less_val(); }
81
82 struct _Val_less_iter
83 {
84#if __cplusplus >= 201103L
85 constexpr _Val_less_iter() = default;
86#else
87 _Val_less_iter() { }
88#endif
89
90 _GLIBCXX20_CONSTEXPR
91 explicit
92 _Val_less_iter(_Iter_less_iter) { }
93
94 template<typename _Value, typename _Iterator>
95 _GLIBCXX20_CONSTEXPR
96 bool
97 operator()(_Value& __val, _Iterator __it) const
98 { return __val < *__it; }
99 };
100
101 _GLIBCXX20_CONSTEXPR
102 inline _Val_less_iter
103 __val_less_iter()
104 { return _Val_less_iter(); }
105
106 _GLIBCXX20_CONSTEXPR
107 inline _Val_less_iter
108 __val_comp_iter(_Iter_less_iter)
109 { return _Val_less_iter(); }
110
111 struct _Iter_equal_to_iter
112 {
113 template<typename _Iterator1, typename _Iterator2>
114 _GLIBCXX20_CONSTEXPR
115 bool
116 operator()(_Iterator1 __it1, _Iterator2 __it2) const
117 { return *__it1 == *__it2; }
118 };
119
120 _GLIBCXX20_CONSTEXPR
121 inline _Iter_equal_to_iter
122 __iter_equal_to_iter()
123 { return _Iter_equal_to_iter(); }
124
125 struct _Iter_equal_to_val
126 {
127 template<typename _Iterator, typename _Value>
128 _GLIBCXX20_CONSTEXPR
129 bool
130 operator()(_Iterator __it, _Value& __val) const
131 { return *__it == __val; }
132 };
133
134 _GLIBCXX20_CONSTEXPR
135 inline _Iter_equal_to_val
136 __iter_equal_to_val()
137 { return _Iter_equal_to_val(); }
138
139 _GLIBCXX20_CONSTEXPR
140 inline _Iter_equal_to_val
141 __iter_comp_val(_Iter_equal_to_iter)
142 { return _Iter_equal_to_val(); }
143
144 template<typename _Compare>
145 struct _Iter_comp_iter
146 {
147 _Compare _M_comp;
148
149 explicit _GLIBCXX14_CONSTEXPR
150 _Iter_comp_iter(_Compare __comp)
151 : _M_comp(_GLIBCXX_MOVE(__comp))
152 { }
153
154 template<typename _Iterator1, typename _Iterator2>
155 _GLIBCXX14_CONSTEXPR
156 bool
157 operator()(_Iterator1 __it1, _Iterator2 __it2)
158 { return bool(_M_comp(*__it1, *__it2)); }
159 };
160
161 template<typename _Compare>
162 _GLIBCXX14_CONSTEXPR
163 inline _Iter_comp_iter<_Compare>
164 __iter_comp_iter(_Compare __comp)
165 { return _Iter_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
166
167 template<typename _Compare>
168 struct _Iter_comp_val
169 {
170 _Compare _M_comp;
171
172 _GLIBCXX20_CONSTEXPR
173 explicit
174 _Iter_comp_val(_Compare __comp)
175 : _M_comp(_GLIBCXX_MOVE(__comp))
176 { }
177
178 _GLIBCXX20_CONSTEXPR
179 explicit
180 _Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp)
181 : _M_comp(__comp._M_comp)
182 { }
183
184#if __cplusplus >= 201103L
185 _GLIBCXX20_CONSTEXPR
186 explicit
187 _Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp)
188 : _M_comp(std::move(__comp._M_comp))
189 { }
190#endif
191
192 template<typename _Iterator, typename _Value>
193 _GLIBCXX20_CONSTEXPR
194 bool
195 operator()(_Iterator __it, _Value& __val)
196 { return bool(_M_comp(*__it, __val)); }
197 };
198
199 template<typename _Compare>
200 _GLIBCXX20_CONSTEXPR
201 inline _Iter_comp_val<_Compare>
202 __iter_comp_val(_Compare __comp)
203 { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); }
204
205 template<typename _Compare>
206 _GLIBCXX20_CONSTEXPR
207 inline _Iter_comp_val<_Compare>
208 __iter_comp_val(_Iter_comp_iter<_Compare> __comp)
209 { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); }
210
211 template<typename _Compare>
212 struct _Val_comp_iter
213 {
214 _Compare _M_comp;
215
216 _GLIBCXX20_CONSTEXPR
217 explicit
218 _Val_comp_iter(_Compare __comp)
219 : _M_comp(_GLIBCXX_MOVE(__comp))
220 { }
221
222 _GLIBCXX20_CONSTEXPR
223 explicit
224 _Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp)
225 : _M_comp(__comp._M_comp)
226 { }
227
228#if __cplusplus >= 201103L
229 _GLIBCXX20_CONSTEXPR
230 explicit
231 _Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp)
232 : _M_comp(std::move(__comp._M_comp))
233 { }
234#endif
235
236 template<typename _Value, typename _Iterator>
237 _GLIBCXX20_CONSTEXPR
238 bool
239 operator()(_Value& __val, _Iterator __it)
240 { return bool(_M_comp(__val, *__it)); }
241 };
242
243 template<typename _Compare>
244 _GLIBCXX20_CONSTEXPR
245 inline _Val_comp_iter<_Compare>
246 __val_comp_iter(_Compare __comp)
247 { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
248
249 template<typename _Compare>
250 _GLIBCXX20_CONSTEXPR
251 inline _Val_comp_iter<_Compare>
252 __val_comp_iter(_Iter_comp_iter<_Compare> __comp)
253 { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
254
255 template<typename _Value>
256 struct _Iter_equals_val
257 {
258 _Value& _M_value;
259
260 _GLIBCXX20_CONSTEXPR
261 explicit
262 _Iter_equals_val(_Value& __value)
263 : _M_value(__value)
264 { }
265
266 template<typename _Iterator>
267 _GLIBCXX20_CONSTEXPR
268 bool
269 operator()(_Iterator __it)
270 { return *__it == _M_value; }
271 };
272
273 template<typename _Value>
274 _GLIBCXX20_CONSTEXPR
275 inline _Iter_equals_val<_Value>
276 __iter_equals_val(_Value& __val)
277 { return _Iter_equals_val<_Value>(__val); }
278
279 template<typename _Iterator1>
280 struct _Iter_equals_iter
281 {
282 _Iterator1 _M_it1;
283
284 _GLIBCXX20_CONSTEXPR
285 explicit
286 _Iter_equals_iter(_Iterator1 __it1)
287 : _M_it1(__it1)
288 { }
289
290 template<typename _Iterator2>
291 _GLIBCXX20_CONSTEXPR
292 bool
293 operator()(_Iterator2 __it2)
294 { return *__it2 == *_M_it1; }
295 };
296
297 template<typename _Iterator>
298 _GLIBCXX20_CONSTEXPR
299 inline _Iter_equals_iter<_Iterator>
300 __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it)
301 { return _Iter_equals_iter<_Iterator>(__it); }
302
303 template<typename _Predicate>
304 struct _Iter_pred
305 {
306 _Predicate _M_pred;
307
308 _GLIBCXX20_CONSTEXPR
309 explicit
310 _Iter_pred(_Predicate __pred)
311 : _M_pred(_GLIBCXX_MOVE(__pred))
312 { }
313
314 template<typename _Iterator>
315 _GLIBCXX20_CONSTEXPR
316 bool
317 operator()(_Iterator __it)
318 { return bool(_M_pred(*__it)); }
319 };
320
321 template<typename _Predicate>
322 _GLIBCXX20_CONSTEXPR
323 inline _Iter_pred<_Predicate>
324 __pred_iter(_Predicate __pred)
325 { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); }
326
327 template<typename _Compare, typename _Value>
328 struct _Iter_comp_to_val
329 {
330 _Compare _M_comp;
331 _Value& _M_value;
332
333 _GLIBCXX20_CONSTEXPR
334 _Iter_comp_to_val(_Compare __comp, _Value& __value)
335 : _M_comp(_GLIBCXX_MOVE(__comp)), _M_value(__value)
336 { }
337
338 template<typename _Iterator>
339 _GLIBCXX20_CONSTEXPR
340 bool
341 operator()(_Iterator __it)
342 { return bool(_M_comp(*__it, _M_value)); }
343 };
344
345 template<typename _Compare, typename _Value>
346 _Iter_comp_to_val<_Compare, _Value>
347 _GLIBCXX20_CONSTEXPR
348 __iter_comp_val(_Compare __comp, _Value &__val)
349 {
350 return _Iter_comp_to_val<_Compare, _Value>(_GLIBCXX_MOVE(__comp), __val);
351 }
352
353 template<typename _Compare, typename _Iterator1>
354 struct _Iter_comp_to_iter
355 {
356 _Compare _M_comp;
357 _Iterator1 _M_it1;
358
359 _GLIBCXX20_CONSTEXPR
360 _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1)
361 : _M_comp(_GLIBCXX_MOVE(__comp)), _M_it1(__it1)
362 { }
363
364 template<typename _Iterator2>
365 _GLIBCXX20_CONSTEXPR
366 bool
367 operator()(_Iterator2 __it2)
368 { return bool(_M_comp(*__it2, *_M_it1)); }
369 };
370
371 template<typename _Compare, typename _Iterator>
372 _GLIBCXX20_CONSTEXPR
373 inline _Iter_comp_to_iter<_Compare, _Iterator>
374 __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it)
375 {
376 return _Iter_comp_to_iter<_Compare, _Iterator>(
377 _GLIBCXX_MOVE(__comp._M_comp), __it);
378 }
379
380 template<typename _Predicate>
381 struct _Iter_negate
382 {
383 _Predicate _M_pred;
384
385 _GLIBCXX20_CONSTEXPR
386 explicit
387 _Iter_negate(_Predicate __pred)
388 : _M_pred(_GLIBCXX_MOVE(__pred))
389 { }
390
391 template<typename _Iterator>
392 _GLIBCXX20_CONSTEXPR
393 bool
394 operator()(_Iterator __it)
395 { return !bool(_M_pred(*__it)); }
396 };
397
398 template<typename _Predicate>
399 _GLIBCXX20_CONSTEXPR
400 inline _Iter_negate<_Predicate>
401 __negate(_Iter_pred<_Predicate> __pred)
402 { return _Iter_negate<_Predicate>(_GLIBCXX_MOVE(__pred._M_pred)); }
403
404} // namespace __ops
405} // namespace __gnu_cxx
406
407#endif
Note: See TracBrowser for help on using the repository browser.