Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __functional / operations.h
blob6cdb89d6b449bcdf12beb80ec528215e4127dcbb
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 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___FUNCTIONAL_OPERATIONS_H
11 #define _LIBCPP___FUNCTIONAL_OPERATIONS_H
13 #include <__config>
14 #include <__functional/binary_function.h>
15 #include <__functional/unary_function.h>
16 #include <__type_traits/integral_constant.h>
17 #include <__type_traits/operation_traits.h>
18 #include <__type_traits/predicate_traits.h>
19 #include <__utility/forward.h>
21 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22 # pragma GCC system_header
23 #endif
25 _LIBCPP_BEGIN_NAMESPACE_STD
27 // Arithmetic operations
29 #if _LIBCPP_STD_VER >= 14
30 template <class _Tp = void>
31 #else
32 template <class _Tp>
33 #endif
34 struct _LIBCPP_TEMPLATE_VIS plus
35 : __binary_function<_Tp, _Tp, _Tp>
37 typedef _Tp __result_type; // used by valarray
38 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
39 _Tp operator()(const _Tp& __x, const _Tp& __y) const
40 {return __x + __y;}
42 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
44 template <class _Tp>
45 struct __is_trivial_plus_operation<plus<_Tp>, _Tp, _Tp> : true_type {};
47 #if _LIBCPP_STD_VER >= 14
48 template <class _Tp, class _Up>
49 struct __is_trivial_plus_operation<plus<>, _Tp, _Up> : true_type {};
50 #endif
52 #if _LIBCPP_STD_VER >= 14
53 template <>
54 struct _LIBCPP_TEMPLATE_VIS plus<void>
56 template <class _T1, class _T2>
57 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
58 auto operator()(_T1&& __t, _T2&& __u) const
59 noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
60 -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
61 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
62 typedef void is_transparent;
64 #endif
66 #if _LIBCPP_STD_VER >= 14
67 template <class _Tp = void>
68 #else
69 template <class _Tp>
70 #endif
71 struct _LIBCPP_TEMPLATE_VIS minus
72 : __binary_function<_Tp, _Tp, _Tp>
74 typedef _Tp __result_type; // used by valarray
75 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
76 _Tp operator()(const _Tp& __x, const _Tp& __y) const
77 {return __x - __y;}
79 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
81 #if _LIBCPP_STD_VER >= 14
82 template <>
83 struct _LIBCPP_TEMPLATE_VIS minus<void>
85 template <class _T1, class _T2>
86 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
87 auto operator()(_T1&& __t, _T2&& __u) const
88 noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
89 -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
90 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
91 typedef void is_transparent;
93 #endif
95 #if _LIBCPP_STD_VER >= 14
96 template <class _Tp = void>
97 #else
98 template <class _Tp>
99 #endif
100 struct _LIBCPP_TEMPLATE_VIS multiplies
101 : __binary_function<_Tp, _Tp, _Tp>
103 typedef _Tp __result_type; // used by valarray
104 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
105 _Tp operator()(const _Tp& __x, const _Tp& __y) const
106 {return __x * __y;}
108 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
110 #if _LIBCPP_STD_VER >= 14
111 template <>
112 struct _LIBCPP_TEMPLATE_VIS multiplies<void>
114 template <class _T1, class _T2>
115 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
116 auto operator()(_T1&& __t, _T2&& __u) const
117 noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
118 -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
119 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
120 typedef void is_transparent;
122 #endif
124 #if _LIBCPP_STD_VER >= 14
125 template <class _Tp = void>
126 #else
127 template <class _Tp>
128 #endif
129 struct _LIBCPP_TEMPLATE_VIS divides
130 : __binary_function<_Tp, _Tp, _Tp>
132 typedef _Tp __result_type; // used by valarray
133 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
134 _Tp operator()(const _Tp& __x, const _Tp& __y) const
135 {return __x / __y;}
137 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
139 #if _LIBCPP_STD_VER >= 14
140 template <>
141 struct _LIBCPP_TEMPLATE_VIS divides<void>
143 template <class _T1, class _T2>
144 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
145 auto operator()(_T1&& __t, _T2&& __u) const
146 noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
147 -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
148 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
149 typedef void is_transparent;
151 #endif
153 #if _LIBCPP_STD_VER >= 14
154 template <class _Tp = void>
155 #else
156 template <class _Tp>
157 #endif
158 struct _LIBCPP_TEMPLATE_VIS modulus
159 : __binary_function<_Tp, _Tp, _Tp>
161 typedef _Tp __result_type; // used by valarray
162 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
163 _Tp operator()(const _Tp& __x, const _Tp& __y) const
164 {return __x % __y;}
166 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
168 #if _LIBCPP_STD_VER >= 14
169 template <>
170 struct _LIBCPP_TEMPLATE_VIS modulus<void>
172 template <class _T1, class _T2>
173 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
174 auto operator()(_T1&& __t, _T2&& __u) const
175 noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
176 -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
177 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
178 typedef void is_transparent;
180 #endif
182 #if _LIBCPP_STD_VER >= 14
183 template <class _Tp = void>
184 #else
185 template <class _Tp>
186 #endif
187 struct _LIBCPP_TEMPLATE_VIS negate
188 : __unary_function<_Tp, _Tp>
190 typedef _Tp __result_type; // used by valarray
191 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
192 _Tp operator()(const _Tp& __x) const
193 {return -__x;}
195 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
197 #if _LIBCPP_STD_VER >= 14
198 template <>
199 struct _LIBCPP_TEMPLATE_VIS negate<void>
201 template <class _Tp>
202 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
203 auto operator()(_Tp&& __x) const
204 noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
205 -> decltype( - _VSTD::forward<_Tp>(__x))
206 { return - _VSTD::forward<_Tp>(__x); }
207 typedef void is_transparent;
209 #endif
211 // Bitwise operations
213 #if _LIBCPP_STD_VER >= 14
214 template <class _Tp = void>
215 #else
216 template <class _Tp>
217 #endif
218 struct _LIBCPP_TEMPLATE_VIS bit_and
219 : __binary_function<_Tp, _Tp, _Tp>
221 typedef _Tp __result_type; // used by valarray
222 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
223 _Tp operator()(const _Tp& __x, const _Tp& __y) const
224 {return __x & __y;}
226 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
228 #if _LIBCPP_STD_VER >= 14
229 template <>
230 struct _LIBCPP_TEMPLATE_VIS bit_and<void>
232 template <class _T1, class _T2>
233 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
234 auto operator()(_T1&& __t, _T2&& __u) const
235 noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
236 -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
237 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
238 typedef void is_transparent;
240 #endif
242 #if _LIBCPP_STD_VER >= 14
243 template <class _Tp = void>
244 struct _LIBCPP_TEMPLATE_VIS bit_not
245 : __unary_function<_Tp, _Tp>
247 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
248 _Tp operator()(const _Tp& __x) const
249 {return ~__x;}
251 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
253 template <>
254 struct _LIBCPP_TEMPLATE_VIS bit_not<void>
256 template <class _Tp>
257 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
258 auto operator()(_Tp&& __x) const
259 noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
260 -> decltype( ~_VSTD::forward<_Tp>(__x))
261 { return ~_VSTD::forward<_Tp>(__x); }
262 typedef void is_transparent;
264 #endif
266 #if _LIBCPP_STD_VER >= 14
267 template <class _Tp = void>
268 #else
269 template <class _Tp>
270 #endif
271 struct _LIBCPP_TEMPLATE_VIS bit_or
272 : __binary_function<_Tp, _Tp, _Tp>
274 typedef _Tp __result_type; // used by valarray
275 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
276 _Tp operator()(const _Tp& __x, const _Tp& __y) const
277 {return __x | __y;}
279 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
281 #if _LIBCPP_STD_VER >= 14
282 template <>
283 struct _LIBCPP_TEMPLATE_VIS bit_or<void>
285 template <class _T1, class _T2>
286 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
287 auto operator()(_T1&& __t, _T2&& __u) const
288 noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
289 -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
290 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
291 typedef void is_transparent;
293 #endif
295 #if _LIBCPP_STD_VER >= 14
296 template <class _Tp = void>
297 #else
298 template <class _Tp>
299 #endif
300 struct _LIBCPP_TEMPLATE_VIS bit_xor
301 : __binary_function<_Tp, _Tp, _Tp>
303 typedef _Tp __result_type; // used by valarray
304 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
305 _Tp operator()(const _Tp& __x, const _Tp& __y) const
306 {return __x ^ __y;}
308 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
310 #if _LIBCPP_STD_VER >= 14
311 template <>
312 struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
314 template <class _T1, class _T2>
315 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
316 auto operator()(_T1&& __t, _T2&& __u) const
317 noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
318 -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
319 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
320 typedef void is_transparent;
322 #endif
324 // Comparison operations
326 #if _LIBCPP_STD_VER >= 14
327 template <class _Tp = void>
328 #else
329 template <class _Tp>
330 #endif
331 struct _LIBCPP_TEMPLATE_VIS equal_to
332 : __binary_function<_Tp, _Tp, bool>
334 typedef bool __result_type; // used by valarray
335 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
336 bool operator()(const _Tp& __x, const _Tp& __y) const
337 {return __x == __y;}
339 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
341 #if _LIBCPP_STD_VER >= 14
342 template <>
343 struct _LIBCPP_TEMPLATE_VIS equal_to<void>
345 template <class _T1, class _T2>
346 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
347 auto operator()(_T1&& __t, _T2&& __u) const
348 noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
349 -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
350 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
351 typedef void is_transparent;
353 #endif
355 template <class _Tp>
356 struct __is_trivial_equality_predicate<equal_to<_Tp>, _Tp, _Tp> : true_type {};
358 #if _LIBCPP_STD_VER >= 14
359 template <class _Tp>
360 struct __is_trivial_equality_predicate<equal_to<>, _Tp, _Tp> : true_type {};
361 #endif
363 #if _LIBCPP_STD_VER >= 14
364 template <class _Tp = void>
365 #else
366 template <class _Tp>
367 #endif
368 struct _LIBCPP_TEMPLATE_VIS not_equal_to
369 : __binary_function<_Tp, _Tp, bool>
371 typedef bool __result_type; // used by valarray
372 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
373 bool operator()(const _Tp& __x, const _Tp& __y) const
374 {return __x != __y;}
376 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
378 #if _LIBCPP_STD_VER >= 14
379 template <>
380 struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
382 template <class _T1, class _T2>
383 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
384 auto operator()(_T1&& __t, _T2&& __u) const
385 noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
386 -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
387 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
388 typedef void is_transparent;
390 #endif
392 #if _LIBCPP_STD_VER >= 14
393 template <class _Tp = void>
394 #else
395 template <class _Tp>
396 #endif
397 struct _LIBCPP_TEMPLATE_VIS less
398 : __binary_function<_Tp, _Tp, bool>
400 typedef bool __result_type; // used by valarray
401 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
402 bool operator()(const _Tp& __x, const _Tp& __y) const
403 {return __x < __y;}
405 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
407 #if _LIBCPP_STD_VER >= 14
408 template <>
409 struct _LIBCPP_TEMPLATE_VIS less<void>
411 template <class _T1, class _T2>
412 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
413 auto operator()(_T1&& __t, _T2&& __u) const
414 noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
415 -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
416 { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
417 typedef void is_transparent;
419 #endif
421 #if _LIBCPP_STD_VER >= 14
422 template <class _Tp = void>
423 #else
424 template <class _Tp>
425 #endif
426 struct _LIBCPP_TEMPLATE_VIS less_equal
427 : __binary_function<_Tp, _Tp, bool>
429 typedef bool __result_type; // used by valarray
430 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
431 bool operator()(const _Tp& __x, const _Tp& __y) const
432 {return __x <= __y;}
434 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
436 #if _LIBCPP_STD_VER >= 14
437 template <>
438 struct _LIBCPP_TEMPLATE_VIS less_equal<void>
440 template <class _T1, class _T2>
441 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
442 auto operator()(_T1&& __t, _T2&& __u) const
443 noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
444 -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
445 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
446 typedef void is_transparent;
448 #endif
450 #if _LIBCPP_STD_VER >= 14
451 template <class _Tp = void>
452 #else
453 template <class _Tp>
454 #endif
455 struct _LIBCPP_TEMPLATE_VIS greater_equal
456 : __binary_function<_Tp, _Tp, bool>
458 typedef bool __result_type; // used by valarray
459 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
460 bool operator()(const _Tp& __x, const _Tp& __y) const
461 {return __x >= __y;}
463 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
465 #if _LIBCPP_STD_VER >= 14
466 template <>
467 struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
469 template <class _T1, class _T2>
470 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
471 auto operator()(_T1&& __t, _T2&& __u) const
472 noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
473 -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
474 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
475 typedef void is_transparent;
477 #endif
479 #if _LIBCPP_STD_VER >= 14
480 template <class _Tp = void>
481 #else
482 template <class _Tp>
483 #endif
484 struct _LIBCPP_TEMPLATE_VIS greater
485 : __binary_function<_Tp, _Tp, bool>
487 typedef bool __result_type; // used by valarray
488 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
489 bool operator()(const _Tp& __x, const _Tp& __y) const
490 {return __x > __y;}
492 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
494 #if _LIBCPP_STD_VER >= 14
495 template <>
496 struct _LIBCPP_TEMPLATE_VIS greater<void>
498 template <class _T1, class _T2>
499 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
500 auto operator()(_T1&& __t, _T2&& __u) const
501 noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
502 -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
503 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
504 typedef void is_transparent;
506 #endif
508 // Logical operations
510 #if _LIBCPP_STD_VER >= 14
511 template <class _Tp = void>
512 #else
513 template <class _Tp>
514 #endif
515 struct _LIBCPP_TEMPLATE_VIS logical_and
516 : __binary_function<_Tp, _Tp, bool>
518 typedef bool __result_type; // used by valarray
519 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
520 bool operator()(const _Tp& __x, const _Tp& __y) const
521 {return __x && __y;}
523 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
525 #if _LIBCPP_STD_VER >= 14
526 template <>
527 struct _LIBCPP_TEMPLATE_VIS logical_and<void>
529 template <class _T1, class _T2>
530 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
531 auto operator()(_T1&& __t, _T2&& __u) const
532 noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
533 -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
534 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
535 typedef void is_transparent;
537 #endif
539 #if _LIBCPP_STD_VER >= 14
540 template <class _Tp = void>
541 #else
542 template <class _Tp>
543 #endif
544 struct _LIBCPP_TEMPLATE_VIS logical_not
545 : __unary_function<_Tp, bool>
547 typedef bool __result_type; // used by valarray
548 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
549 bool operator()(const _Tp& __x) const
550 {return !__x;}
552 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
554 #if _LIBCPP_STD_VER >= 14
555 template <>
556 struct _LIBCPP_TEMPLATE_VIS logical_not<void>
558 template <class _Tp>
559 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
560 auto operator()(_Tp&& __x) const
561 noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
562 -> decltype( !_VSTD::forward<_Tp>(__x))
563 { return !_VSTD::forward<_Tp>(__x); }
564 typedef void is_transparent;
566 #endif
568 #if _LIBCPP_STD_VER >= 14
569 template <class _Tp = void>
570 #else
571 template <class _Tp>
572 #endif
573 struct _LIBCPP_TEMPLATE_VIS logical_or
574 : __binary_function<_Tp, _Tp, bool>
576 typedef bool __result_type; // used by valarray
577 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
578 bool operator()(const _Tp& __x, const _Tp& __y) const
579 {return __x || __y;}
581 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
583 #if _LIBCPP_STD_VER >= 14
584 template <>
585 struct _LIBCPP_TEMPLATE_VIS logical_or<void>
587 template <class _T1, class _T2>
588 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
589 auto operator()(_T1&& __t, _T2&& __u) const
590 noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
591 -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
592 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
593 typedef void is_transparent;
595 #endif
597 _LIBCPP_END_NAMESPACE_STD
599 #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H