xref: /freebsd/contrib/llvm-project/libcxx/include/__functional/operations.h (revision d5b0e70f7e04d971691517ce1304d86a1e367e2e)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef _LIBCPP___FUNCTIONAL_OPERATIONS_H
11 #define _LIBCPP___FUNCTIONAL_OPERATIONS_H
12 
13 #include <__config>
14 #include <__functional/binary_function.h>
15 #include <__functional/unary_function.h>
16 #include <__utility/forward.h>
17 
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 #pragma GCC system_header
20 #endif
21 
22 _LIBCPP_BEGIN_NAMESPACE_STD
23 
24 // Arithmetic operations
25 
26 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
27 #if _LIBCPP_STD_VER > 11
28 template <class _Tp = void>
29 #else
30 template <class _Tp>
31 #endif
32 struct _LIBCPP_TEMPLATE_VIS plus
33 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
34     : binary_function<_Tp, _Tp, _Tp>
35 #endif
36 {
37 _LIBCPP_SUPPRESS_DEPRECATED_POP
38     typedef _Tp __result_type;  // used by valarray
39 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
40     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
41     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
42     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
43 #endif
44     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
45     _Tp operator()(const _Tp& __x, const _Tp& __y) const
46         {return __x + __y;}
47 };
48 
49 #if _LIBCPP_STD_VER > 11
50 template <>
51 struct _LIBCPP_TEMPLATE_VIS plus<void>
52 {
53     template <class _T1, class _T2>
54     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
55     auto operator()(_T1&& __t, _T2&& __u) const
56         noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
57         -> decltype(      _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
58         { return          _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
59     typedef void is_transparent;
60 };
61 #endif
62 
63 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
64 #if _LIBCPP_STD_VER > 11
65 template <class _Tp = void>
66 #else
67 template <class _Tp>
68 #endif
69 struct _LIBCPP_TEMPLATE_VIS minus
70 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
71     : binary_function<_Tp, _Tp, _Tp>
72 #endif
73 {
74 _LIBCPP_SUPPRESS_DEPRECATED_POP
75     typedef _Tp __result_type;  // used by valarray
76 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
77     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
78     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
79     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
80 #endif
81     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
82     _Tp operator()(const _Tp& __x, const _Tp& __y) const
83         {return __x - __y;}
84 };
85 
86 #if _LIBCPP_STD_VER > 11
87 template <>
88 struct _LIBCPP_TEMPLATE_VIS minus<void>
89 {
90     template <class _T1, class _T2>
91     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
92     auto operator()(_T1&& __t, _T2&& __u) const
93         noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
94         -> decltype(      _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
95         { return          _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
96     typedef void is_transparent;
97 };
98 #endif
99 
100 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
101 #if _LIBCPP_STD_VER > 11
102 template <class _Tp = void>
103 #else
104 template <class _Tp>
105 #endif
106 struct _LIBCPP_TEMPLATE_VIS multiplies
107 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
108     : binary_function<_Tp, _Tp, _Tp>
109 #endif
110 {
111 _LIBCPP_SUPPRESS_DEPRECATED_POP
112     typedef _Tp __result_type;  // used by valarray
113 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
114     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
115     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
116     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
117 #endif
118     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
119     _Tp operator()(const _Tp& __x, const _Tp& __y) const
120         {return __x * __y;}
121 };
122 
123 #if _LIBCPP_STD_VER > 11
124 template <>
125 struct _LIBCPP_TEMPLATE_VIS multiplies<void>
126 {
127     template <class _T1, class _T2>
128     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
129     auto operator()(_T1&& __t, _T2&& __u) const
130         noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
131         -> decltype(      _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
132         { return          _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
133     typedef void is_transparent;
134 };
135 #endif
136 
137 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
138 #if _LIBCPP_STD_VER > 11
139 template <class _Tp = void>
140 #else
141 template <class _Tp>
142 #endif
143 struct _LIBCPP_TEMPLATE_VIS divides
144 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
145     : binary_function<_Tp, _Tp, _Tp>
146 #endif
147 {
148 _LIBCPP_SUPPRESS_DEPRECATED_POP
149     typedef _Tp __result_type;  // used by valarray
150 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
151     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
152     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
153     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
154 #endif
155     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
156     _Tp operator()(const _Tp& __x, const _Tp& __y) const
157         {return __x / __y;}
158 };
159 
160 #if _LIBCPP_STD_VER > 11
161 template <>
162 struct _LIBCPP_TEMPLATE_VIS divides<void>
163 {
164     template <class _T1, class _T2>
165     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
166     auto operator()(_T1&& __t, _T2&& __u) const
167         noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
168         -> decltype(      _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
169         { return          _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
170     typedef void is_transparent;
171 };
172 #endif
173 
174 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
175 #if _LIBCPP_STD_VER > 11
176 template <class _Tp = void>
177 #else
178 template <class _Tp>
179 #endif
180 struct _LIBCPP_TEMPLATE_VIS modulus
181 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
182     : binary_function<_Tp, _Tp, _Tp>
183 #endif
184 {
185 _LIBCPP_SUPPRESS_DEPRECATED_POP
186     typedef _Tp __result_type;  // used by valarray
187 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
188     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
189     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
190     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
191 #endif
192     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
193     _Tp operator()(const _Tp& __x, const _Tp& __y) const
194         {return __x % __y;}
195 };
196 
197 #if _LIBCPP_STD_VER > 11
198 template <>
199 struct _LIBCPP_TEMPLATE_VIS modulus<void>
200 {
201     template <class _T1, class _T2>
202     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
203     auto operator()(_T1&& __t, _T2&& __u) const
204         noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
205         -> decltype(      _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
206         { return          _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
207     typedef void is_transparent;
208 };
209 #endif
210 
211 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
212 #if _LIBCPP_STD_VER > 11
213 template <class _Tp = void>
214 #else
215 template <class _Tp>
216 #endif
217 struct _LIBCPP_TEMPLATE_VIS negate
218 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
219     : unary_function<_Tp, _Tp>
220 #endif
221 {
222 _LIBCPP_SUPPRESS_DEPRECATED_POP
223     typedef _Tp __result_type;  // used by valarray
224 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
225     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
226     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
227 #endif
228     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
229     _Tp operator()(const _Tp& __x) const
230         {return -__x;}
231 };
232 
233 #if _LIBCPP_STD_VER > 11
234 template <>
235 struct _LIBCPP_TEMPLATE_VIS negate<void>
236 {
237     template <class _Tp>
238     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
239     auto operator()(_Tp&& __x) const
240         noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
241         -> decltype(      - _VSTD::forward<_Tp>(__x))
242         { return          - _VSTD::forward<_Tp>(__x); }
243     typedef void is_transparent;
244 };
245 #endif
246 
247 // Bitwise operations
248 
249 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
250 #if _LIBCPP_STD_VER > 11
251 template <class _Tp = void>
252 #else
253 template <class _Tp>
254 #endif
255 struct _LIBCPP_TEMPLATE_VIS bit_and
256 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
257     : binary_function<_Tp, _Tp, _Tp>
258 #endif
259 {
260 _LIBCPP_SUPPRESS_DEPRECATED_POP
261     typedef _Tp __result_type;  // used by valarray
262 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
263     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
264     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
265     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
266 #endif
267     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
268     _Tp operator()(const _Tp& __x, const _Tp& __y) const
269         {return __x & __y;}
270 };
271 
272 #if _LIBCPP_STD_VER > 11
273 template <>
274 struct _LIBCPP_TEMPLATE_VIS bit_and<void>
275 {
276     template <class _T1, class _T2>
277     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
278     auto operator()(_T1&& __t, _T2&& __u) const
279         noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
280         -> decltype(      _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
281         { return          _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
282     typedef void is_transparent;
283 };
284 #endif
285 
286 #if _LIBCPP_STD_VER > 11
287 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
288 template <class _Tp = void>
289 struct _LIBCPP_TEMPLATE_VIS bit_not
290 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
291     : unary_function<_Tp, _Tp>
292 #endif
293 {
294 _LIBCPP_SUPPRESS_DEPRECATED_POP
295 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
296     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
297     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
298 #endif
299     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
300     _Tp operator()(const _Tp& __x) const
301         {return ~__x;}
302 };
303 
304 template <>
305 struct _LIBCPP_TEMPLATE_VIS bit_not<void>
306 {
307     template <class _Tp>
308     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
309     auto operator()(_Tp&& __x) const
310         noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
311         -> decltype(      ~_VSTD::forward<_Tp>(__x))
312         { return          ~_VSTD::forward<_Tp>(__x); }
313     typedef void is_transparent;
314 };
315 #endif
316 
317 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
318 #if _LIBCPP_STD_VER > 11
319 template <class _Tp = void>
320 #else
321 template <class _Tp>
322 #endif
323 struct _LIBCPP_TEMPLATE_VIS bit_or
324 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
325     : binary_function<_Tp, _Tp, _Tp>
326 #endif
327 {
328 _LIBCPP_SUPPRESS_DEPRECATED_POP
329     typedef _Tp __result_type;  // used by valarray
330 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
331     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
332     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
333     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
334 #endif
335     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
336     _Tp operator()(const _Tp& __x, const _Tp& __y) const
337         {return __x | __y;}
338 };
339 
340 #if _LIBCPP_STD_VER > 11
341 template <>
342 struct _LIBCPP_TEMPLATE_VIS bit_or<void>
343 {
344     template <class _T1, class _T2>
345     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
346     auto operator()(_T1&& __t, _T2&& __u) const
347         noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
348         -> decltype(      _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
349         { return          _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
350     typedef void is_transparent;
351 };
352 #endif
353 
354 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
355 #if _LIBCPP_STD_VER > 11
356 template <class _Tp = void>
357 #else
358 template <class _Tp>
359 #endif
360 struct _LIBCPP_TEMPLATE_VIS bit_xor
361 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
362     : binary_function<_Tp, _Tp, _Tp>
363 #endif
364 {
365 _LIBCPP_SUPPRESS_DEPRECATED_POP
366     typedef _Tp __result_type;  // used by valarray
367 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
368     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
369     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
370     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
371 #endif
372     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
373     _Tp operator()(const _Tp& __x, const _Tp& __y) const
374         {return __x ^ __y;}
375 };
376 
377 #if _LIBCPP_STD_VER > 11
378 template <>
379 struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
380 {
381     template <class _T1, class _T2>
382     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
383     auto operator()(_T1&& __t, _T2&& __u) const
384         noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
385         -> decltype(      _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
386         { return          _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
387     typedef void is_transparent;
388 };
389 #endif
390 
391 // Comparison operations
392 
393 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
394 #if _LIBCPP_STD_VER > 11
395 template <class _Tp = void>
396 #else
397 template <class _Tp>
398 #endif
399 struct _LIBCPP_TEMPLATE_VIS equal_to
400 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
401     : binary_function<_Tp, _Tp, bool>
402 #endif
403 {
404 _LIBCPP_SUPPRESS_DEPRECATED_POP
405     typedef bool __result_type;  // used by valarray
406 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
407     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
408     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
409     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
410 #endif
411     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
412     bool operator()(const _Tp& __x, const _Tp& __y) const
413         {return __x == __y;}
414 };
415 
416 #if _LIBCPP_STD_VER > 11
417 template <>
418 struct _LIBCPP_TEMPLATE_VIS equal_to<void>
419 {
420     template <class _T1, class _T2>
421     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
422     auto operator()(_T1&& __t, _T2&& __u) const
423         noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
424         -> decltype(      _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
425         { return          _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
426     typedef void is_transparent;
427 };
428 #endif
429 
430 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
431 #if _LIBCPP_STD_VER > 11
432 template <class _Tp = void>
433 #else
434 template <class _Tp>
435 #endif
436 struct _LIBCPP_TEMPLATE_VIS not_equal_to
437 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
438     : binary_function<_Tp, _Tp, bool>
439 #endif
440 {
441 _LIBCPP_SUPPRESS_DEPRECATED_POP
442     typedef bool __result_type;  // used by valarray
443 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
444     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
445     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
446     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
447 #endif
448     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
449     bool operator()(const _Tp& __x, const _Tp& __y) const
450         {return __x != __y;}
451 };
452 
453 #if _LIBCPP_STD_VER > 11
454 template <>
455 struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
456 {
457     template <class _T1, class _T2>
458     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
459     auto operator()(_T1&& __t, _T2&& __u) const
460         noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
461         -> decltype(      _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
462         { return          _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
463     typedef void is_transparent;
464 };
465 #endif
466 
467 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
468 #if _LIBCPP_STD_VER > 11
469 template <class _Tp = void>
470 #else
471 template <class _Tp>
472 #endif
473 struct _LIBCPP_TEMPLATE_VIS less
474 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
475     : binary_function<_Tp, _Tp, bool>
476 #endif
477 {
478 _LIBCPP_SUPPRESS_DEPRECATED_POP
479     typedef bool __result_type;  // used by valarray
480 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
481     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
482     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
483     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
484 #endif
485     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
486     bool operator()(const _Tp& __x, const _Tp& __y) const
487         {return __x < __y;}
488 };
489 
490 #if _LIBCPP_STD_VER > 11
491 template <>
492 struct _LIBCPP_TEMPLATE_VIS less<void>
493 {
494     template <class _T1, class _T2>
495     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
496     auto operator()(_T1&& __t, _T2&& __u) const
497         noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
498         -> decltype(      _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
499         { return          _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
500     typedef void is_transparent;
501 };
502 #endif
503 
504 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
505 #if _LIBCPP_STD_VER > 11
506 template <class _Tp = void>
507 #else
508 template <class _Tp>
509 #endif
510 struct _LIBCPP_TEMPLATE_VIS less_equal
511 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
512     : binary_function<_Tp, _Tp, bool>
513 #endif
514 {
515 _LIBCPP_SUPPRESS_DEPRECATED_POP
516     typedef bool __result_type;  // used by valarray
517 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
518     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
519     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
520     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
521 #endif
522     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
523     bool operator()(const _Tp& __x, const _Tp& __y) const
524         {return __x <= __y;}
525 };
526 
527 #if _LIBCPP_STD_VER > 11
528 template <>
529 struct _LIBCPP_TEMPLATE_VIS less_equal<void>
530 {
531     template <class _T1, class _T2>
532     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
533     auto operator()(_T1&& __t, _T2&& __u) const
534         noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
535         -> decltype(      _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
536         { return          _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
537     typedef void is_transparent;
538 };
539 #endif
540 
541 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
542 #if _LIBCPP_STD_VER > 11
543 template <class _Tp = void>
544 #else
545 template <class _Tp>
546 #endif
547 struct _LIBCPP_TEMPLATE_VIS greater_equal
548 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
549     : binary_function<_Tp, _Tp, bool>
550 #endif
551 {
552 _LIBCPP_SUPPRESS_DEPRECATED_POP
553     typedef bool __result_type;  // used by valarray
554 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
555     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
556     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
557     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
558 #endif
559     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
560     bool operator()(const _Tp& __x, const _Tp& __y) const
561         {return __x >= __y;}
562 };
563 
564 #if _LIBCPP_STD_VER > 11
565 template <>
566 struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
567 {
568     template <class _T1, class _T2>
569     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
570     auto operator()(_T1&& __t, _T2&& __u) const
571         noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
572         -> decltype(      _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
573         { return          _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
574     typedef void is_transparent;
575 };
576 #endif
577 
578 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
579 #if _LIBCPP_STD_VER > 11
580 template <class _Tp = void>
581 #else
582 template <class _Tp>
583 #endif
584 struct _LIBCPP_TEMPLATE_VIS greater
585 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
586     : binary_function<_Tp, _Tp, bool>
587 #endif
588 {
589 _LIBCPP_SUPPRESS_DEPRECATED_POP
590     typedef bool __result_type;  // used by valarray
591 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
592     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
593     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
594     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
595 #endif
596     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
597     bool operator()(const _Tp& __x, const _Tp& __y) const
598         {return __x > __y;}
599 };
600 
601 #if _LIBCPP_STD_VER > 11
602 template <>
603 struct _LIBCPP_TEMPLATE_VIS greater<void>
604 {
605     template <class _T1, class _T2>
606     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
607     auto operator()(_T1&& __t, _T2&& __u) const
608         noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
609         -> decltype(      _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
610         { return          _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
611     typedef void is_transparent;
612 };
613 #endif
614 
615 // Logical operations
616 
617 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
618 #if _LIBCPP_STD_VER > 11
619 template <class _Tp = void>
620 #else
621 template <class _Tp>
622 #endif
623 struct _LIBCPP_TEMPLATE_VIS logical_and
624 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
625     : binary_function<_Tp, _Tp, bool>
626 #endif
627 {
628 _LIBCPP_SUPPRESS_DEPRECATED_POP
629     typedef bool __result_type;  // used by valarray
630 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
631     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
632     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
633     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
634 #endif
635     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
636     bool operator()(const _Tp& __x, const _Tp& __y) const
637         {return __x && __y;}
638 };
639 
640 #if _LIBCPP_STD_VER > 11
641 template <>
642 struct _LIBCPP_TEMPLATE_VIS logical_and<void>
643 {
644     template <class _T1, class _T2>
645     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
646     auto operator()(_T1&& __t, _T2&& __u) const
647         noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
648         -> decltype(      _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
649         { return          _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
650     typedef void is_transparent;
651 };
652 #endif
653 
654 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
655 #if _LIBCPP_STD_VER > 11
656 template <class _Tp = void>
657 #else
658 template <class _Tp>
659 #endif
660 struct _LIBCPP_TEMPLATE_VIS logical_not
661 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
662     : unary_function<_Tp, bool>
663 #endif
664 {
665 _LIBCPP_SUPPRESS_DEPRECATED_POP
666     typedef bool __result_type;  // used by valarray
667 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
668     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
669     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
670 #endif
671     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
672     bool operator()(const _Tp& __x) const
673         {return !__x;}
674 };
675 
676 #if _LIBCPP_STD_VER > 11
677 template <>
678 struct _LIBCPP_TEMPLATE_VIS logical_not<void>
679 {
680     template <class _Tp>
681     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
682     auto operator()(_Tp&& __x) const
683         noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
684         -> decltype(      !_VSTD::forward<_Tp>(__x))
685         { return          !_VSTD::forward<_Tp>(__x); }
686     typedef void is_transparent;
687 };
688 #endif
689 
690 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
691 #if _LIBCPP_STD_VER > 11
692 template <class _Tp = void>
693 #else
694 template <class _Tp>
695 #endif
696 struct _LIBCPP_TEMPLATE_VIS logical_or
697 #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
698     : binary_function<_Tp, _Tp, bool>
699 #endif
700 {
701 _LIBCPP_SUPPRESS_DEPRECATED_POP
702     typedef bool __result_type;  // used by valarray
703 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
704     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
705     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
706     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
707 #endif
708     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
709     bool operator()(const _Tp& __x, const _Tp& __y) const
710         {return __x || __y;}
711 };
712 
713 #if _LIBCPP_STD_VER > 11
714 template <>
715 struct _LIBCPP_TEMPLATE_VIS logical_or<void>
716 {
717     template <class _T1, class _T2>
718     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
719     auto operator()(_T1&& __t, _T2&& __u) const
720         noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
721         -> decltype(      _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
722         { return          _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
723     typedef void is_transparent;
724 };
725 #endif
726 
727 _LIBCPP_END_NAMESPACE_STD
728 
729 #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
730