]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/bits/predefined_ops.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / predefined_ops.h
CommitLineData
ea89b248
FD
1// Default predicates for internal use -*- C++ -*-
2
8d9254fc 3// Copyright (C) 2013-2020 Free Software Foundation, Inc.
ea89b248
FD
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.
2cf9276b 27 * You should not attempt to use it directly. @headername{algorithm}
ea89b248
FD
28 */
29
30#ifndef _GLIBCXX_PREDEFINED_OPS_H
31#define _GLIBCXX_PREDEFINED_OPS_H 1
32
33namespace __gnu_cxx
34{
35namespace __ops
36{
37 struct _Iter_less_iter
38 {
39 template<typename _Iterator1, typename _Iterator2>
8dff34fe 40 _GLIBCXX14_CONSTEXPR
ea89b248
FD
41 bool
42 operator()(_Iterator1 __it1, _Iterator2 __it2) const
43 { return *__it1 < *__it2; }
44 };
6807f086 45
8dff34fe 46 _GLIBCXX14_CONSTEXPR
ea89b248
FD
47 inline _Iter_less_iter
48 __iter_less_iter()
49 { return _Iter_less_iter(); }
50
51 struct _Iter_less_val
52 {
437f43cc
JW
53#if __cplusplus >= 201103L
54 constexpr _Iter_less_val() = default;
55#else
56 _Iter_less_val() { }
57#endif
58
3a66e68a 59 _GLIBCXX20_CONSTEXPR
437f43cc
JW
60 explicit
61 _Iter_less_val(_Iter_less_iter) { }
62
ea89b248 63 template<typename _Iterator, typename _Value>
3a66e68a 64 _GLIBCXX20_CONSTEXPR
ea89b248
FD
65 bool
66 operator()(_Iterator __it, _Value& __val) const
67 { return *__it < __val; }
6807f086 68 };
ea89b248 69
3a66e68a 70 _GLIBCXX20_CONSTEXPR
ea89b248
FD
71 inline _Iter_less_val
72 __iter_less_val()
73 { return _Iter_less_val(); }
74
3a66e68a 75 _GLIBCXX20_CONSTEXPR
ea89b248
FD
76 inline _Iter_less_val
77 __iter_comp_val(_Iter_less_iter)
78 { return _Iter_less_val(); }
79
80 struct _Val_less_iter
81 {
437f43cc
JW
82#if __cplusplus >= 201103L
83 constexpr _Val_less_iter() = default;
84#else
85 _Val_less_iter() { }
86#endif
87
3a66e68a 88 _GLIBCXX20_CONSTEXPR
437f43cc
JW
89 explicit
90 _Val_less_iter(_Iter_less_iter) { }
91
ea89b248 92 template<typename _Value, typename _Iterator>
3a66e68a 93 _GLIBCXX20_CONSTEXPR
ea89b248
FD
94 bool
95 operator()(_Value& __val, _Iterator __it) const
96 { return __val < *__it; }
6807f086 97 };
ea89b248 98
3a66e68a 99 _GLIBCXX20_CONSTEXPR
ea89b248
FD
100 inline _Val_less_iter
101 __val_less_iter()
102 { return _Val_less_iter(); }
103
3a66e68a 104 _GLIBCXX20_CONSTEXPR
ea89b248
FD
105 inline _Val_less_iter
106 __val_comp_iter(_Iter_less_iter)
107 { return _Val_less_iter(); }
108
109 struct _Iter_equal_to_iter
110 {
111 template<typename _Iterator1, typename _Iterator2>
3a66e68a 112 _GLIBCXX20_CONSTEXPR
ea89b248
FD
113 bool
114 operator()(_Iterator1 __it1, _Iterator2 __it2) const
115 { return *__it1 == *__it2; }
6807f086 116 };
ea89b248 117
3a66e68a 118 _GLIBCXX20_CONSTEXPR
ea89b248
FD
119 inline _Iter_equal_to_iter
120 __iter_equal_to_iter()
121 { return _Iter_equal_to_iter(); }
122
123 struct _Iter_equal_to_val
124 {
125 template<typename _Iterator, typename _Value>
3a66e68a 126 _GLIBCXX20_CONSTEXPR
ea89b248
FD
127 bool
128 operator()(_Iterator __it, _Value& __val) const
129 { return *__it == __val; }
6807f086 130 };
ea89b248 131
3a66e68a 132 _GLIBCXX20_CONSTEXPR
ea89b248
FD
133 inline _Iter_equal_to_val
134 __iter_equal_to_val()
135 { return _Iter_equal_to_val(); }
136
3a66e68a 137 _GLIBCXX20_CONSTEXPR
ea89b248
FD
138 inline _Iter_equal_to_val
139 __iter_comp_val(_Iter_equal_to_iter)
140 { return _Iter_equal_to_val(); }
141
142 template<typename _Compare>
143 struct _Iter_comp_iter
144 {
145 _Compare _M_comp;
6807f086
JW
146
147 explicit _GLIBCXX14_CONSTEXPR
ea89b248 148 _Iter_comp_iter(_Compare __comp)
6807f086 149 : _M_comp(_GLIBCXX_MOVE(__comp))
ea89b248
FD
150 { }
151
152 template<typename _Iterator1, typename _Iterator2>
8dff34fe 153 _GLIBCXX14_CONSTEXPR
ea89b248
FD
154 bool
155 operator()(_Iterator1 __it1, _Iterator2 __it2)
156 { return bool(_M_comp(*__it1, *__it2)); }
157 };
158
159 template<typename _Compare>
8dff34fe 160 _GLIBCXX14_CONSTEXPR
ea89b248
FD
161 inline _Iter_comp_iter<_Compare>
162 __iter_comp_iter(_Compare __comp)
6807f086 163 { return _Iter_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
ea89b248
FD
164
165 template<typename _Compare>
166 struct _Iter_comp_val
167 {
168 _Compare _M_comp;
169
3a66e68a 170 _GLIBCXX20_CONSTEXPR
6807f086 171 explicit
ea89b248 172 _Iter_comp_val(_Compare __comp)
6807f086 173 : _M_comp(_GLIBCXX_MOVE(__comp))
ea89b248
FD
174 { }
175
3a66e68a 176 _GLIBCXX20_CONSTEXPR
437f43cc
JW
177 explicit
178 _Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp)
179 : _M_comp(__comp._M_comp)
180 { }
181
182#if __cplusplus >= 201103L
3a66e68a 183 _GLIBCXX20_CONSTEXPR
437f43cc
JW
184 explicit
185 _Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp)
186 : _M_comp(std::move(__comp._M_comp))
187 { }
188#endif
189
ea89b248 190 template<typename _Iterator, typename _Value>
3a66e68a 191 _GLIBCXX20_CONSTEXPR
ea89b248
FD
192 bool
193 operator()(_Iterator __it, _Value& __val)
194 { return bool(_M_comp(*__it, __val)); }
195 };
196
197 template<typename _Compare>
3a66e68a
ESR
198 _GLIBCXX20_CONSTEXPR
199 inline _Iter_comp_val<_Compare>
ea89b248 200 __iter_comp_val(_Compare __comp)
6807f086 201 { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); }
ea89b248
FD
202
203 template<typename _Compare>
3a66e68a 204 _GLIBCXX20_CONSTEXPR
ea89b248
FD
205 inline _Iter_comp_val<_Compare>
206 __iter_comp_val(_Iter_comp_iter<_Compare> __comp)
437f43cc 207 { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); }
ea89b248
FD
208
209 template<typename _Compare>
210 struct _Val_comp_iter
211 {
212 _Compare _M_comp;
213
3a66e68a 214 _GLIBCXX20_CONSTEXPR
6807f086 215 explicit
ea89b248 216 _Val_comp_iter(_Compare __comp)
6807f086 217 : _M_comp(_GLIBCXX_MOVE(__comp))
ea89b248
FD
218 { }
219
3a66e68a 220 _GLIBCXX20_CONSTEXPR
437f43cc
JW
221 explicit
222 _Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp)
223 : _M_comp(__comp._M_comp)
224 { }
225
226#if __cplusplus >= 201103L
3a66e68a 227 _GLIBCXX20_CONSTEXPR
437f43cc
JW
228 explicit
229 _Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp)
230 : _M_comp(std::move(__comp._M_comp))
231 { }
232#endif
233
ea89b248 234 template<typename _Value, typename _Iterator>
3a66e68a 235 _GLIBCXX20_CONSTEXPR
ea89b248
FD
236 bool
237 operator()(_Value& __val, _Iterator __it)
238 { return bool(_M_comp(__val, *__it)); }
239 };
240
241 template<typename _Compare>
3a66e68a 242 _GLIBCXX20_CONSTEXPR
ea89b248
FD
243 inline _Val_comp_iter<_Compare>
244 __val_comp_iter(_Compare __comp)
6807f086 245 { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
ea89b248
FD
246
247 template<typename _Compare>
3a66e68a 248 _GLIBCXX20_CONSTEXPR
ea89b248
FD
249 inline _Val_comp_iter<_Compare>
250 __val_comp_iter(_Iter_comp_iter<_Compare> __comp)
437f43cc 251 { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); }
ea89b248
FD
252
253 template<typename _Value>
254 struct _Iter_equals_val
255 {
256 _Value& _M_value;
257
3a66e68a 258 _GLIBCXX20_CONSTEXPR
6807f086 259 explicit
ea89b248
FD
260 _Iter_equals_val(_Value& __value)
261 : _M_value(__value)
262 { }
263
264 template<typename _Iterator>
3a66e68a 265 _GLIBCXX20_CONSTEXPR
ea89b248
FD
266 bool
267 operator()(_Iterator __it)
268 { return *__it == _M_value; }
269 };
270
271 template<typename _Value>
3a66e68a 272 _GLIBCXX20_CONSTEXPR
ea89b248
FD
273 inline _Iter_equals_val<_Value>
274 __iter_equals_val(_Value& __val)
275 { return _Iter_equals_val<_Value>(__val); }
276
277 template<typename _Iterator1>
278 struct _Iter_equals_iter
279 {
2cf9276b 280 _Iterator1 _M_it1;
ea89b248 281
3a66e68a 282 _GLIBCXX20_CONSTEXPR
6807f086 283 explicit
ea89b248 284 _Iter_equals_iter(_Iterator1 __it1)
2cf9276b 285 : _M_it1(__it1)
ea89b248
FD
286 { }
287
288 template<typename _Iterator2>
3a66e68a 289 _GLIBCXX20_CONSTEXPR
ea89b248
FD
290 bool
291 operator()(_Iterator2 __it2)
2cf9276b 292 { return *__it2 == *_M_it1; }
ea89b248
FD
293 };
294
295 template<typename _Iterator>
3a66e68a 296 _GLIBCXX20_CONSTEXPR
ea89b248
FD
297 inline _Iter_equals_iter<_Iterator>
298 __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it)
299 { return _Iter_equals_iter<_Iterator>(__it); }
300
301 template<typename _Predicate>
302 struct _Iter_pred
303 {
304 _Predicate _M_pred;
305
3a66e68a 306 _GLIBCXX20_CONSTEXPR
6807f086 307 explicit
ea89b248 308 _Iter_pred(_Predicate __pred)
6807f086 309 : _M_pred(_GLIBCXX_MOVE(__pred))
ea89b248
FD
310 { }
311
312 template<typename _Iterator>
3a66e68a 313 _GLIBCXX20_CONSTEXPR
ea89b248
FD
314 bool
315 operator()(_Iterator __it)
316 { return bool(_M_pred(*__it)); }
317 };
318
319 template<typename _Predicate>
3a66e68a 320 _GLIBCXX20_CONSTEXPR
ea89b248
FD
321 inline _Iter_pred<_Predicate>
322 __pred_iter(_Predicate __pred)
6807f086 323 { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); }
ea89b248
FD
324
325 template<typename _Compare, typename _Value>
326 struct _Iter_comp_to_val
327 {
328 _Compare _M_comp;
329 _Value& _M_value;
330
3a66e68a 331 _GLIBCXX20_CONSTEXPR
ea89b248 332 _Iter_comp_to_val(_Compare __comp, _Value& __value)
6807f086 333 : _M_comp(_GLIBCXX_MOVE(__comp)), _M_value(__value)
ea89b248
FD
334 { }
335
336 template<typename _Iterator>
3a66e68a 337 _GLIBCXX20_CONSTEXPR
ea89b248
FD
338 bool
339 operator()(_Iterator __it)
340 { return bool(_M_comp(*__it, _M_value)); }
341 };
342
343 template<typename _Compare, typename _Value>
344 _Iter_comp_to_val<_Compare, _Value>
3a66e68a 345 _GLIBCXX20_CONSTEXPR
ea89b248 346 __iter_comp_val(_Compare __comp, _Value &__val)
6807f086
JW
347 {
348 return _Iter_comp_to_val<_Compare, _Value>(_GLIBCXX_MOVE(__comp), __val);
349 }
ea89b248
FD
350
351 template<typename _Compare, typename _Iterator1>
352 struct _Iter_comp_to_iter
353 {
354 _Compare _M_comp;
2cf9276b 355 _Iterator1 _M_it1;
ea89b248 356
3a66e68a 357 _GLIBCXX20_CONSTEXPR
ea89b248 358 _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1)
2cf9276b 359 : _M_comp(_GLIBCXX_MOVE(__comp)), _M_it1(__it1)
ea89b248
FD
360 { }
361
362 template<typename _Iterator2>
3a66e68a 363 _GLIBCXX20_CONSTEXPR
ea89b248
FD
364 bool
365 operator()(_Iterator2 __it2)
2cf9276b 366 { return bool(_M_comp(*__it2, *_M_it1)); }
ea89b248
FD
367 };
368
369 template<typename _Compare, typename _Iterator>
3a66e68a 370 _GLIBCXX20_CONSTEXPR
ea89b248
FD
371 inline _Iter_comp_to_iter<_Compare, _Iterator>
372 __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it)
6807f086
JW
373 {
374 return _Iter_comp_to_iter<_Compare, _Iterator>(
375 _GLIBCXX_MOVE(__comp._M_comp), __it);
376 }
ea89b248
FD
377
378 template<typename _Predicate>
379 struct _Iter_negate
380 {
381 _Predicate _M_pred;
382
3a66e68a 383 _GLIBCXX20_CONSTEXPR
6807f086 384 explicit
ea89b248 385 _Iter_negate(_Predicate __pred)
6807f086 386 : _M_pred(_GLIBCXX_MOVE(__pred))
ea89b248
FD
387 { }
388
389 template<typename _Iterator>
3a66e68a 390 _GLIBCXX20_CONSTEXPR
ea89b248
FD
391 bool
392 operator()(_Iterator __it)
393 { return !bool(_M_pred(*__it)); }
394 };
395
396 template<typename _Predicate>
3a66e68a 397 _GLIBCXX20_CONSTEXPR
ea89b248
FD
398 inline _Iter_negate<_Predicate>
399 __negate(_Iter_pred<_Predicate> __pred)
6807f086 400 { return _Iter_negate<_Predicate>(_GLIBCXX_MOVE(__pred._M_pred)); }
ea89b248
FD
401
402} // namespace __ops
403} // namespace __gnu_cxx
404
405#endif