• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <__type_traits/integral_constant.h>
17 #include <__type_traits/operation_traits.h>
18 #include <__utility/forward.h>
19 
20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21 #  pragma GCC system_header
22 #endif
23 
24 _LIBCPP_BEGIN_NAMESPACE_STD
25 
26 // Arithmetic operations
27 
28 #if _LIBCPP_STD_VER >= 14
29 template <class _Tp = void>
30 #else
31 template <class _Tp>
32 #endif
33 struct _LIBCPP_TEMPLATE_VIS plus
34     : __binary_function<_Tp, _Tp, _Tp>
35 {
36     typedef _Tp __result_type;  // used by valarray
37     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
operatorplus38     _Tp operator()(const _Tp& __x, const _Tp& __y) const
39         {return __x + __y;}
40 };
41 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
42 
43 // The non-transparent std::plus specialization is only equivalent to a raw plus
44 // operator when we don't perform an implicit conversion when calling it.
45 template <class _Tp>
46 struct __desugars_to<__plus_tag, plus<_Tp>, _Tp, _Tp> : true_type {};
47 
48 template <class _Tp, class _Up>
49 struct __desugars_to<__plus_tag, plus<void>, _Tp, _Up> : true_type {};
50 
51 #if _LIBCPP_STD_VER >= 14
52 template <>
53 struct _LIBCPP_TEMPLATE_VIS plus<void>
54 {
55     template <class _T1, class _T2>
56     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
57     auto operator()(_T1&& __t, _T2&& __u) const
58         noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
59         -> decltype(      _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
60         { return          _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
61     typedef void is_transparent;
62 };
63 #endif
64 
65 #if _LIBCPP_STD_VER >= 14
66 template <class _Tp = void>
67 #else
68 template <class _Tp>
69 #endif
70 struct _LIBCPP_TEMPLATE_VIS minus
71     : __binary_function<_Tp, _Tp, _Tp>
72 {
73     typedef _Tp __result_type;  // used by valarray
74     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
75     _Tp operator()(const _Tp& __x, const _Tp& __y) const
76         {return __x - __y;}
77 };
78 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
79 
80 #if _LIBCPP_STD_VER >= 14
81 template <>
82 struct _LIBCPP_TEMPLATE_VIS minus<void>
83 {
84     template <class _T1, class _T2>
85     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
86     auto operator()(_T1&& __t, _T2&& __u) const
87         noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
88         -> decltype(      _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
89         { return          _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
90     typedef void is_transparent;
91 };
92 #endif
93 
94 #if _LIBCPP_STD_VER >= 14
95 template <class _Tp = void>
96 #else
97 template <class _Tp>
98 #endif
99 struct _LIBCPP_TEMPLATE_VIS multiplies
100     : __binary_function<_Tp, _Tp, _Tp>
101 {
102     typedef _Tp __result_type;  // used by valarray
103     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
104     _Tp operator()(const _Tp& __x, const _Tp& __y) const
105         {return __x * __y;}
106 };
107 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
108 
109 #if _LIBCPP_STD_VER >= 14
110 template <>
111 struct _LIBCPP_TEMPLATE_VIS multiplies<void>
112 {
113     template <class _T1, class _T2>
114     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
115     auto operator()(_T1&& __t, _T2&& __u) const
116         noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
117         -> decltype(      _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
118         { return          _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
119     typedef void is_transparent;
120 };
121 #endif
122 
123 #if _LIBCPP_STD_VER >= 14
124 template <class _Tp = void>
125 #else
126 template <class _Tp>
127 #endif
128 struct _LIBCPP_TEMPLATE_VIS divides
129     : __binary_function<_Tp, _Tp, _Tp>
130 {
131     typedef _Tp __result_type;  // used by valarray
132     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
133     _Tp operator()(const _Tp& __x, const _Tp& __y) const
134         {return __x / __y;}
135 };
136 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
137 
138 #if _LIBCPP_STD_VER >= 14
139 template <>
140 struct _LIBCPP_TEMPLATE_VIS divides<void>
141 {
142     template <class _T1, class _T2>
143     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
144     auto operator()(_T1&& __t, _T2&& __u) const
145         noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
146         -> decltype(      _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
147         { return          _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
148     typedef void is_transparent;
149 };
150 #endif
151 
152 #if _LIBCPP_STD_VER >= 14
153 template <class _Tp = void>
154 #else
155 template <class _Tp>
156 #endif
157 struct _LIBCPP_TEMPLATE_VIS modulus
158     : __binary_function<_Tp, _Tp, _Tp>
159 {
160     typedef _Tp __result_type;  // used by valarray
161     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
162     _Tp operator()(const _Tp& __x, const _Tp& __y) const
163         {return __x % __y;}
164 };
165 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
166 
167 #if _LIBCPP_STD_VER >= 14
168 template <>
169 struct _LIBCPP_TEMPLATE_VIS modulus<void>
170 {
171     template <class _T1, class _T2>
172     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
173     auto operator()(_T1&& __t, _T2&& __u) const
174         noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
175         -> decltype(      _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
176         { return          _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
177     typedef void is_transparent;
178 };
179 #endif
180 
181 #if _LIBCPP_STD_VER >= 14
182 template <class _Tp = void>
183 #else
184 template <class _Tp>
185 #endif
186 struct _LIBCPP_TEMPLATE_VIS negate
187     : __unary_function<_Tp, _Tp>
188 {
189     typedef _Tp __result_type;  // used by valarray
190     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
191     _Tp operator()(const _Tp& __x) const
192         {return -__x;}
193 };
194 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
195 
196 #if _LIBCPP_STD_VER >= 14
197 template <>
198 struct _LIBCPP_TEMPLATE_VIS negate<void>
199 {
200     template <class _Tp>
201     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
202     auto operator()(_Tp&& __x) const
203         noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
204         -> decltype(      - _VSTD::forward<_Tp>(__x))
205         { return          - _VSTD::forward<_Tp>(__x); }
206     typedef void is_transparent;
207 };
208 #endif
209 
210 // Bitwise operations
211 
212 #if _LIBCPP_STD_VER >= 14
213 template <class _Tp = void>
214 #else
215 template <class _Tp>
216 #endif
217 struct _LIBCPP_TEMPLATE_VIS bit_and
218     : __binary_function<_Tp, _Tp, _Tp>
219 {
220     typedef _Tp __result_type;  // used by valarray
221     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
222     _Tp operator()(const _Tp& __x, const _Tp& __y) const
223         {return __x & __y;}
224 };
225 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
226 
227 #if _LIBCPP_STD_VER >= 14
228 template <>
229 struct _LIBCPP_TEMPLATE_VIS bit_and<void>
230 {
231     template <class _T1, class _T2>
232     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
233     auto operator()(_T1&& __t, _T2&& __u) const
234         noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
235         -> decltype(      _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
236         { return          _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
237     typedef void is_transparent;
238 };
239 #endif
240 
241 #if _LIBCPP_STD_VER >= 14
242 template <class _Tp = void>
243 struct _LIBCPP_TEMPLATE_VIS bit_not
244     : __unary_function<_Tp, _Tp>
245 {
246     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
247     _Tp operator()(const _Tp& __x) const
248         {return ~__x;}
249 };
250 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
251 
252 template <>
253 struct _LIBCPP_TEMPLATE_VIS bit_not<void>
254 {
255     template <class _Tp>
256     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
257     auto operator()(_Tp&& __x) const
258         noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
259         -> decltype(      ~_VSTD::forward<_Tp>(__x))
260         { return          ~_VSTD::forward<_Tp>(__x); }
261     typedef void is_transparent;
262 };
263 #endif
264 
265 #if _LIBCPP_STD_VER >= 14
266 template <class _Tp = void>
267 #else
268 template <class _Tp>
269 #endif
270 struct _LIBCPP_TEMPLATE_VIS bit_or
271     : __binary_function<_Tp, _Tp, _Tp>
272 {
273     typedef _Tp __result_type;  // used by valarray
274     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
275     _Tp operator()(const _Tp& __x, const _Tp& __y) const
276         {return __x | __y;}
277 };
278 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
279 
280 #if _LIBCPP_STD_VER >= 14
281 template <>
282 struct _LIBCPP_TEMPLATE_VIS bit_or<void>
283 {
284     template <class _T1, class _T2>
285     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
286     auto operator()(_T1&& __t, _T2&& __u) const
287         noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
288         -> decltype(      _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
289         { return          _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
290     typedef void is_transparent;
291 };
292 #endif
293 
294 #if _LIBCPP_STD_VER >= 14
295 template <class _Tp = void>
296 #else
297 template <class _Tp>
298 #endif
299 struct _LIBCPP_TEMPLATE_VIS bit_xor
300     : __binary_function<_Tp, _Tp, _Tp>
301 {
302     typedef _Tp __result_type;  // used by valarray
303     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
304     _Tp operator()(const _Tp& __x, const _Tp& __y) const
305         {return __x ^ __y;}
306 };
307 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
308 
309 #if _LIBCPP_STD_VER >= 14
310 template <>
311 struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
312 {
313     template <class _T1, class _T2>
314     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
315     auto operator()(_T1&& __t, _T2&& __u) const
316         noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
317         -> decltype(      _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
318         { return          _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
319     typedef void is_transparent;
320 };
321 #endif
322 
323 // Comparison operations
324 
325 #if _LIBCPP_STD_VER >= 14
326 template <class _Tp = void>
327 #else
328 template <class _Tp>
329 #endif
330 struct _LIBCPP_TEMPLATE_VIS equal_to
331     : __binary_function<_Tp, _Tp, bool>
332 {
333     typedef bool __result_type;  // used by valarray
334     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
335     bool operator()(const _Tp& __x, const _Tp& __y) const
336         {return __x == __y;}
337 };
338 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
339 
340 #if _LIBCPP_STD_VER >= 14
341 template <>
342 struct _LIBCPP_TEMPLATE_VIS equal_to<void>
343 {
344     template <class _T1, class _T2>
345     _LIBCPP_CONSTEXPR_SINCE_CXX14 _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 // The non-transparent std::equal_to specialization is only equivalent to a raw equality
355 // comparison when we don't perform an implicit conversion when calling it.
356 template <class _Tp>
357 struct __desugars_to<__equal_tag, equal_to<_Tp>, _Tp, _Tp> : true_type {};
358 
359 // In the transparent case, we do not enforce that
360 template <class _Tp, class _Up>
361 struct __desugars_to<__equal_tag, equal_to<void>, _Tp, _Up> : true_type {};
362 
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>
370 {
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;}
375 };
376 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
377 
378 #if _LIBCPP_STD_VER >= 14
379 template <>
380 struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
381 {
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;
389 };
390 #endif
391 
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>
399 {
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;}
404 };
405 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
406 
407 #if _LIBCPP_STD_VER >= 14
408 template <>
409 struct _LIBCPP_TEMPLATE_VIS less<void>
410 {
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;
418 };
419 #endif
420 
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>
428 {
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;}
433 };
434 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
435 
436 #if _LIBCPP_STD_VER >= 14
437 template <>
438 struct _LIBCPP_TEMPLATE_VIS less_equal<void>
439 {
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;
447 };
448 #endif
449 
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>
457 {
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;}
462 };
463 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
464 
465 #if _LIBCPP_STD_VER >= 14
466 template <>
467 struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
468 {
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;
476 };
477 #endif
478 
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>
486 {
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;}
491 };
492 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
493 
494 #if _LIBCPP_STD_VER >= 14
495 template <>
496 struct _LIBCPP_TEMPLATE_VIS greater<void>
497 {
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;
505 };
506 #endif
507 
508 // Logical operations
509 
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>
517 {
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;}
522 };
523 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
524 
525 #if _LIBCPP_STD_VER >= 14
526 template <>
527 struct _LIBCPP_TEMPLATE_VIS logical_and<void>
528 {
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;
536 };
537 #endif
538 
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>
546 {
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;}
551 };
552 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
553 
554 #if _LIBCPP_STD_VER >= 14
555 template <>
556 struct _LIBCPP_TEMPLATE_VIS logical_not<void>
557 {
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;
565 };
566 #endif
567 
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>
575 {
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;}
580 };
581 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
582 
583 #if _LIBCPP_STD_VER >= 14
584 template <>
585 struct _LIBCPP_TEMPLATE_VIS logical_or<void>
586 {
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;
594 };
595 #endif
596 
597 _LIBCPP_END_NAMESPACE_STD
598 
599 #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
600