]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/bits/predefined_ops.h
1 // Default predicates for internal use -*- C++ -*-
3 // Copyright (C) 2013-2017 Free Software Foundation, Inc.
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)
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.
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.
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/>.
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}
30 #ifndef _GLIBCXX_PREDEFINED_OPS_H
31 #define _GLIBCXX_PREDEFINED_OPS_H 1
37 struct _Iter_less_iter
39 template<typename _Iterator1
, typename _Iterator2
>
42 operator()(_Iterator1 __it1
, _Iterator2 __it2
) const
43 { return *__it1
< *__it2
; }
47 inline _Iter_less_iter
49 { return _Iter_less_iter(); }
53 #if __cplusplus >= 201103L
54 constexpr _Iter_less_val() = default;
60 _Iter_less_val(_Iter_less_iter
) { }
62 template<typename _Iterator
, typename _Value
>
64 operator()(_Iterator __it
, _Value
& __val
) const
65 { return *__it
< __val
; }
70 { return _Iter_less_val(); }
73 __iter_comp_val(_Iter_less_iter
)
74 { return _Iter_less_val(); }
78 #if __cplusplus >= 201103L
79 constexpr _Val_less_iter() = default;
85 _Val_less_iter(_Iter_less_iter
) { }
87 template<typename _Value
, typename _Iterator
>
89 operator()(_Value
& __val
, _Iterator __it
) const
90 { return __val
< *__it
; }
95 { return _Val_less_iter(); }
98 __val_comp_iter(_Iter_less_iter
)
99 { return _Val_less_iter(); }
101 struct _Iter_equal_to_iter
103 template<typename _Iterator1
, typename _Iterator2
>
105 operator()(_Iterator1 __it1
, _Iterator2 __it2
) const
106 { return *__it1
== *__it2
; }
109 inline _Iter_equal_to_iter
110 __iter_equal_to_iter()
111 { return _Iter_equal_to_iter(); }
113 struct _Iter_equal_to_val
115 template<typename _Iterator
, typename _Value
>
117 operator()(_Iterator __it
, _Value
& __val
) const
118 { return *__it
== __val
; }
121 inline _Iter_equal_to_val
122 __iter_equal_to_val()
123 { return _Iter_equal_to_val(); }
125 inline _Iter_equal_to_val
126 __iter_comp_val(_Iter_equal_to_iter
)
127 { return _Iter_equal_to_val(); }
129 template<typename _Compare
>
130 struct _Iter_comp_iter
134 explicit _GLIBCXX14_CONSTEXPR
135 _Iter_comp_iter(_Compare __comp
)
136 : _M_comp(_GLIBCXX_MOVE(__comp
))
139 template<typename _Iterator1
, typename _Iterator2
>
142 operator()(_Iterator1 __it1
, _Iterator2 __it2
)
143 { return bool(_M_comp(*__it1
, *__it2
)); }
146 template<typename _Compare
>
148 inline _Iter_comp_iter
<_Compare
>
149 __iter_comp_iter(_Compare __comp
)
150 { return _Iter_comp_iter
<_Compare
>(_GLIBCXX_MOVE(__comp
)); }
152 template<typename _Compare
>
153 struct _Iter_comp_val
158 _Iter_comp_val(_Compare __comp
)
159 : _M_comp(_GLIBCXX_MOVE(__comp
))
163 _Iter_comp_val(const _Iter_comp_iter
<_Compare
>& __comp
)
164 : _M_comp(__comp
._M_comp
)
167 #if __cplusplus >= 201103L
169 _Iter_comp_val(_Iter_comp_iter
<_Compare
>&& __comp
)
170 : _M_comp(std::move(__comp
._M_comp
))
174 template<typename _Iterator
, typename _Value
>
176 operator()(_Iterator __it
, _Value
& __val
)
177 { return bool(_M_comp(*__it
, __val
)); }
180 template<typename _Compare
>
181 inline _Iter_comp_val
<_Compare
>
182 __iter_comp_val(_Compare __comp
)
183 { return _Iter_comp_val
<_Compare
>(_GLIBCXX_MOVE(__comp
)); }
185 template<typename _Compare
>
186 inline _Iter_comp_val
<_Compare
>
187 __iter_comp_val(_Iter_comp_iter
<_Compare
> __comp
)
188 { return _Iter_comp_val
<_Compare
>(_GLIBCXX_MOVE(__comp
)); }
190 template<typename _Compare
>
191 struct _Val_comp_iter
196 _Val_comp_iter(_Compare __comp
)
197 : _M_comp(_GLIBCXX_MOVE(__comp
))
201 _Val_comp_iter(const _Iter_comp_iter
<_Compare
>& __comp
)
202 : _M_comp(__comp
._M_comp
)
205 #if __cplusplus >= 201103L
207 _Val_comp_iter(_Iter_comp_iter
<_Compare
>&& __comp
)
208 : _M_comp(std::move(__comp
._M_comp
))
212 template<typename _Value
, typename _Iterator
>
214 operator()(_Value
& __val
, _Iterator __it
)
215 { return bool(_M_comp(__val
, *__it
)); }
218 template<typename _Compare
>
219 inline _Val_comp_iter
<_Compare
>
220 __val_comp_iter(_Compare __comp
)
221 { return _Val_comp_iter
<_Compare
>(_GLIBCXX_MOVE(__comp
)); }
223 template<typename _Compare
>
224 inline _Val_comp_iter
<_Compare
>
225 __val_comp_iter(_Iter_comp_iter
<_Compare
> __comp
)
226 { return _Val_comp_iter
<_Compare
>(_GLIBCXX_MOVE(__comp
)); }
228 template<typename _Value
>
229 struct _Iter_equals_val
234 _Iter_equals_val(_Value
& __value
)
238 template<typename _Iterator
>
240 operator()(_Iterator __it
)
241 { return *__it
== _M_value
; }
244 template<typename _Value
>
245 inline _Iter_equals_val
<_Value
>
246 __iter_equals_val(_Value
& __val
)
247 { return _Iter_equals_val
<_Value
>(__val
); }
249 template<typename _Iterator1
>
250 struct _Iter_equals_iter
255 _Iter_equals_iter(_Iterator1 __it1
)
259 template<typename _Iterator2
>
261 operator()(_Iterator2 __it2
)
262 { return *__it2
== *_M_it1
; }
265 template<typename _Iterator
>
266 inline _Iter_equals_iter
<_Iterator
>
267 __iter_comp_iter(_Iter_equal_to_iter
, _Iterator __it
)
268 { return _Iter_equals_iter
<_Iterator
>(__it
); }
270 template<typename _Predicate
>
276 _Iter_pred(_Predicate __pred
)
277 : _M_pred(_GLIBCXX_MOVE(__pred
))
280 template<typename _Iterator
>
282 operator()(_Iterator __it
)
283 { return bool(_M_pred(*__it
)); }
286 template<typename _Predicate
>
287 inline _Iter_pred
<_Predicate
>
288 __pred_iter(_Predicate __pred
)
289 { return _Iter_pred
<_Predicate
>(_GLIBCXX_MOVE(__pred
)); }
291 template<typename _Compare
, typename _Value
>
292 struct _Iter_comp_to_val
297 _Iter_comp_to_val(_Compare __comp
, _Value
& __value
)
298 : _M_comp(_GLIBCXX_MOVE(__comp
)), _M_value(__value
)
301 template<typename _Iterator
>
303 operator()(_Iterator __it
)
304 { return bool(_M_comp(*__it
, _M_value
)); }
307 template<typename _Compare
, typename _Value
>
308 _Iter_comp_to_val
<_Compare
, _Value
>
309 __iter_comp_val(_Compare __comp
, _Value
&__val
)
311 return _Iter_comp_to_val
<_Compare
, _Value
>(_GLIBCXX_MOVE(__comp
), __val
);
314 template<typename _Compare
, typename _Iterator1
>
315 struct _Iter_comp_to_iter
320 _Iter_comp_to_iter(_Compare __comp
, _Iterator1 __it1
)
321 : _M_comp(_GLIBCXX_MOVE(__comp
)), _M_it1(__it1
)
324 template<typename _Iterator2
>
326 operator()(_Iterator2 __it2
)
327 { return bool(_M_comp(*__it2
, *_M_it1
)); }
330 template<typename _Compare
, typename _Iterator
>
331 inline _Iter_comp_to_iter
<_Compare
, _Iterator
>
332 __iter_comp_iter(_Iter_comp_iter
<_Compare
> __comp
, _Iterator __it
)
334 return _Iter_comp_to_iter
<_Compare
, _Iterator
>(
335 _GLIBCXX_MOVE(__comp
._M_comp
), __it
);
338 template<typename _Predicate
>
344 _Iter_negate(_Predicate __pred
)
345 : _M_pred(_GLIBCXX_MOVE(__pred
))
348 template<typename _Iterator
>
350 operator()(_Iterator __it
)
351 { return !bool(_M_pred(*__it
)); }
354 template<typename _Predicate
>
355 inline _Iter_negate
<_Predicate
>
356 __negate(_Iter_pred
<_Predicate
> __pred
)
357 { return _Iter_negate
<_Predicate
>(_GLIBCXX_MOVE(__pred
._M_pred
)); }
360 } // namespace __gnu_cxx