1 // Default predicates for internal use -*- C++ -*-
3 // Copyright (C) 2013-2015 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.
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
; }
46 inline _Iter_less_iter
48 { return _Iter_less_iter(); }
52 template<typename _Iterator
, typename _Value
>
54 operator()(_Iterator __it
, _Value
& __val
) const
55 { return *__it
< __val
; }
60 { return _Iter_less_val(); }
63 __iter_comp_val(_Iter_less_iter
)
64 { return _Iter_less_val(); }
68 template<typename _Value
, typename _Iterator
>
70 operator()(_Value
& __val
, _Iterator __it
) const
71 { return __val
< *__it
; }
76 { return _Val_less_iter(); }
79 __val_comp_iter(_Iter_less_iter
)
80 { return _Val_less_iter(); }
82 struct _Iter_equal_to_iter
84 template<typename _Iterator1
, typename _Iterator2
>
86 operator()(_Iterator1 __it1
, _Iterator2 __it2
) const
87 { return *__it1
== *__it2
; }
90 inline _Iter_equal_to_iter
91 __iter_equal_to_iter()
92 { return _Iter_equal_to_iter(); }
94 struct _Iter_equal_to_val
96 template<typename _Iterator
, typename _Value
>
98 operator()(_Iterator __it
, _Value
& __val
) const
99 { return *__it
== __val
; }
102 inline _Iter_equal_to_val
103 __iter_equal_to_val()
104 { return _Iter_equal_to_val(); }
106 inline _Iter_equal_to_val
107 __iter_comp_val(_Iter_equal_to_iter
)
108 { return _Iter_equal_to_val(); }
110 template<typename _Compare
>
111 struct _Iter_comp_iter
115 _Iter_comp_iter(_Compare __comp
)
119 template<typename _Iterator1
, typename _Iterator2
>
122 operator()(_Iterator1 __it1
, _Iterator2 __it2
)
123 { return bool(_M_comp(*__it1
, *__it2
)); }
126 template<typename _Compare
>
128 inline _Iter_comp_iter
<_Compare
>
129 __iter_comp_iter(_Compare __comp
)
130 { return _Iter_comp_iter
<_Compare
>(__comp
); }
132 template<typename _Compare
>
133 struct _Iter_comp_val
137 _Iter_comp_val(_Compare __comp
)
141 template<typename _Iterator
, typename _Value
>
143 operator()(_Iterator __it
, _Value
& __val
)
144 { return bool(_M_comp(*__it
, __val
)); }
147 template<typename _Compare
>
148 inline _Iter_comp_val
<_Compare
>
149 __iter_comp_val(_Compare __comp
)
150 { return _Iter_comp_val
<_Compare
>(__comp
); }
152 template<typename _Compare
>
153 inline _Iter_comp_val
<_Compare
>
154 __iter_comp_val(_Iter_comp_iter
<_Compare
> __comp
)
155 { return _Iter_comp_val
<_Compare
>(__comp
._M_comp
); }
157 template<typename _Compare
>
158 struct _Val_comp_iter
162 _Val_comp_iter(_Compare __comp
)
166 template<typename _Value
, typename _Iterator
>
168 operator()(_Value
& __val
, _Iterator __it
)
169 { return bool(_M_comp(__val
, *__it
)); }
172 template<typename _Compare
>
173 inline _Val_comp_iter
<_Compare
>
174 __val_comp_iter(_Compare __comp
)
175 { return _Val_comp_iter
<_Compare
>(__comp
); }
177 template<typename _Compare
>
178 inline _Val_comp_iter
<_Compare
>
179 __val_comp_iter(_Iter_comp_iter
<_Compare
> __comp
)
180 { return _Val_comp_iter
<_Compare
>(__comp
._M_comp
); }
182 template<typename _Value
>
183 struct _Iter_equals_val
187 _Iter_equals_val(_Value
& __value
)
191 template<typename _Iterator
>
193 operator()(_Iterator __it
)
194 { return *__it
== _M_value
; }
197 template<typename _Value
>
198 inline _Iter_equals_val
<_Value
>
199 __iter_equals_val(_Value
& __val
)
200 { return _Iter_equals_val
<_Value
>(__val
); }
202 template<typename _Iterator1
>
203 struct _Iter_equals_iter
205 typename
std::iterator_traits
<_Iterator1
>::reference _M_ref
;
207 _Iter_equals_iter(_Iterator1 __it1
)
211 template<typename _Iterator2
>
213 operator()(_Iterator2 __it2
)
214 { return *__it2
== _M_ref
; }
217 template<typename _Iterator
>
218 inline _Iter_equals_iter
<_Iterator
>
219 __iter_comp_iter(_Iter_equal_to_iter
, _Iterator __it
)
220 { return _Iter_equals_iter
<_Iterator
>(__it
); }
222 template<typename _Predicate
>
227 _Iter_pred(_Predicate __pred
)
231 template<typename _Iterator
>
233 operator()(_Iterator __it
)
234 { return bool(_M_pred(*__it
)); }
237 template<typename _Predicate
>
238 inline _Iter_pred
<_Predicate
>
239 __pred_iter(_Predicate __pred
)
240 { return _Iter_pred
<_Predicate
>(__pred
); }
242 template<typename _Compare
, typename _Value
>
243 struct _Iter_comp_to_val
248 _Iter_comp_to_val(_Compare __comp
, _Value
& __value
)
249 : _M_comp(__comp
), _M_value(__value
)
252 template<typename _Iterator
>
254 operator()(_Iterator __it
)
255 { return bool(_M_comp(*__it
, _M_value
)); }
258 template<typename _Compare
, typename _Value
>
259 _Iter_comp_to_val
<_Compare
, _Value
>
260 __iter_comp_val(_Compare __comp
, _Value
&__val
)
261 { return _Iter_comp_to_val
<_Compare
, _Value
>(__comp
, __val
); }
263 template<typename _Compare
, typename _Iterator1
>
264 struct _Iter_comp_to_iter
267 typename
std::iterator_traits
<_Iterator1
>::reference _M_ref
;
269 _Iter_comp_to_iter(_Compare __comp
, _Iterator1 __it1
)
270 : _M_comp(__comp
), _M_ref(*__it1
)
273 template<typename _Iterator2
>
275 operator()(_Iterator2 __it2
)
276 { return bool(_M_comp(*__it2
, _M_ref
)); }
279 template<typename _Compare
, typename _Iterator
>
280 inline _Iter_comp_to_iter
<_Compare
, _Iterator
>
281 __iter_comp_iter(_Iter_comp_iter
<_Compare
> __comp
, _Iterator __it
)
282 { return _Iter_comp_to_iter
<_Compare
, _Iterator
>(__comp
._M_comp
, __it
); }
284 template<typename _Predicate
>
289 _Iter_negate(_Predicate __pred
)
293 template<typename _Iterator
>
295 operator()(_Iterator __it
)
296 { return !bool(_M_pred(*__it
)); }
299 template<typename _Predicate
>
300 inline _Iter_negate
<_Predicate
>
301 __negate(_Iter_pred
<_Predicate
> __pred
)
302 { return _Iter_negate
<_Predicate
>(__pred
._M_pred
); }
305 } // namespace __gnu_cxx