• 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/desugars_to.h>
17 #include <__type_traits/is_integral.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 : __binary_function<_Tp, _Tp, _Tp> {
34   typedef _Tp __result_type; // used by valarray
operatorplus35   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
36     return __x + __y;
37   }
38 };
39 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
40 
41 // The non-transparent std::plus specialization is only equivalent to a raw plus
42 // operator when we don't perform an implicit conversion when calling it.
43 template <class _Tp>
44 inline const bool __desugars_to_v<__plus_tag, plus<_Tp>, _Tp, _Tp> = true;
45 
46 template <class _Tp, class _Up>
47 inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true;
48 
49 #if _LIBCPP_STD_VER >= 14
50 template <>
51 struct _LIBCPP_TEMPLATE_VIS plus<void> {
52   template <class _T1, class _T2>
53   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
54       noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) //
55       -> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) {
56     return std::forward<_T1>(__t) + std::forward<_T2>(__u);
57   }
58   typedef void is_transparent;
59 };
60 #endif
61 
62 #if _LIBCPP_STD_VER >= 14
63 template <class _Tp = void>
64 #else
65 template <class _Tp>
66 #endif
67 struct _LIBCPP_TEMPLATE_VIS minus : __binary_function<_Tp, _Tp, _Tp> {
68   typedef _Tp __result_type; // used by valarray
69   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
70     return __x - __y;
71   }
72 };
73 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
74 
75 #if _LIBCPP_STD_VER >= 14
76 template <>
77 struct _LIBCPP_TEMPLATE_VIS minus<void> {
78   template <class _T1, class _T2>
79   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
80       noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) //
81       -> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) {
82     return std::forward<_T1>(__t) - std::forward<_T2>(__u);
83   }
84   typedef void is_transparent;
85 };
86 #endif
87 
88 #if _LIBCPP_STD_VER >= 14
89 template <class _Tp = void>
90 #else
91 template <class _Tp>
92 #endif
93 struct _LIBCPP_TEMPLATE_VIS multiplies : __binary_function<_Tp, _Tp, _Tp> {
94   typedef _Tp __result_type; // used by valarray
95   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
96     return __x * __y;
97   }
98 };
99 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
100 
101 #if _LIBCPP_STD_VER >= 14
102 template <>
103 struct _LIBCPP_TEMPLATE_VIS multiplies<void> {
104   template <class _T1, class _T2>
105   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
106       noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) //
107       -> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) {
108     return std::forward<_T1>(__t) * std::forward<_T2>(__u);
109   }
110   typedef void is_transparent;
111 };
112 #endif
113 
114 #if _LIBCPP_STD_VER >= 14
115 template <class _Tp = void>
116 #else
117 template <class _Tp>
118 #endif
119 struct _LIBCPP_TEMPLATE_VIS divides : __binary_function<_Tp, _Tp, _Tp> {
120   typedef _Tp __result_type; // used by valarray
121   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
122     return __x / __y;
123   }
124 };
125 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
126 
127 #if _LIBCPP_STD_VER >= 14
128 template <>
129 struct _LIBCPP_TEMPLATE_VIS divides<void> {
130   template <class _T1, class _T2>
131   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
132       noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) //
133       -> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) {
134     return std::forward<_T1>(__t) / std::forward<_T2>(__u);
135   }
136   typedef void is_transparent;
137 };
138 #endif
139 
140 #if _LIBCPP_STD_VER >= 14
141 template <class _Tp = void>
142 #else
143 template <class _Tp>
144 #endif
145 struct _LIBCPP_TEMPLATE_VIS modulus : __binary_function<_Tp, _Tp, _Tp> {
146   typedef _Tp __result_type; // used by valarray
147   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
148     return __x % __y;
149   }
150 };
151 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
152 
153 #if _LIBCPP_STD_VER >= 14
154 template <>
155 struct _LIBCPP_TEMPLATE_VIS modulus<void> {
156   template <class _T1, class _T2>
157   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
158       noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) //
159       -> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) {
160     return std::forward<_T1>(__t) % std::forward<_T2>(__u);
161   }
162   typedef void is_transparent;
163 };
164 #endif
165 
166 #if _LIBCPP_STD_VER >= 14
167 template <class _Tp = void>
168 #else
169 template <class _Tp>
170 #endif
171 struct _LIBCPP_TEMPLATE_VIS negate : __unary_function<_Tp, _Tp> {
172   typedef _Tp __result_type; // used by valarray
173   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; }
174 };
175 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
176 
177 #if _LIBCPP_STD_VER >= 14
178 template <>
179 struct _LIBCPP_TEMPLATE_VIS negate<void> {
180   template <class _Tp>
181   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
182       noexcept(noexcept(-std::forward<_Tp>(__x))) //
183       -> decltype(-std::forward<_Tp>(__x)) {
184     return -std::forward<_Tp>(__x);
185   }
186   typedef void is_transparent;
187 };
188 #endif
189 
190 // Bitwise operations
191 
192 #if _LIBCPP_STD_VER >= 14
193 template <class _Tp = void>
194 #else
195 template <class _Tp>
196 #endif
197 struct _LIBCPP_TEMPLATE_VIS bit_and : __binary_function<_Tp, _Tp, _Tp> {
198   typedef _Tp __result_type; // used by valarray
199   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
200     return __x & __y;
201   }
202 };
203 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
204 
205 #if _LIBCPP_STD_VER >= 14
206 template <>
207 struct _LIBCPP_TEMPLATE_VIS bit_and<void> {
208   template <class _T1, class _T2>
209   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
210       noexcept(noexcept(std::forward<_T1>(__t) &
211                         std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) {
212     return std::forward<_T1>(__t) & std::forward<_T2>(__u);
213   }
214   typedef void is_transparent;
215 };
216 #endif
217 
218 #if _LIBCPP_STD_VER >= 14
219 template <class _Tp = void>
220 struct _LIBCPP_TEMPLATE_VIS bit_not : __unary_function<_Tp, _Tp> {
221   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }
222 };
223 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
224 
225 template <>
226 struct _LIBCPP_TEMPLATE_VIS bit_not<void> {
227   template <class _Tp>
228   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
229       noexcept(noexcept(~std::forward<_Tp>(__x))) //
230       -> decltype(~std::forward<_Tp>(__x)) {
231     return ~std::forward<_Tp>(__x);
232   }
233   typedef void is_transparent;
234 };
235 #endif
236 
237 #if _LIBCPP_STD_VER >= 14
238 template <class _Tp = void>
239 #else
240 template <class _Tp>
241 #endif
242 struct _LIBCPP_TEMPLATE_VIS bit_or : __binary_function<_Tp, _Tp, _Tp> {
243   typedef _Tp __result_type; // used by valarray
244   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
245     return __x | __y;
246   }
247 };
248 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
249 
250 #if _LIBCPP_STD_VER >= 14
251 template <>
252 struct _LIBCPP_TEMPLATE_VIS bit_or<void> {
253   template <class _T1, class _T2>
254   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
255       noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) //
256       -> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) {
257     return std::forward<_T1>(__t) | std::forward<_T2>(__u);
258   }
259   typedef void is_transparent;
260 };
261 #endif
262 
263 #if _LIBCPP_STD_VER >= 14
264 template <class _Tp = void>
265 #else
266 template <class _Tp>
267 #endif
268 struct _LIBCPP_TEMPLATE_VIS bit_xor : __binary_function<_Tp, _Tp, _Tp> {
269   typedef _Tp __result_type; // used by valarray
270   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
271     return __x ^ __y;
272   }
273 };
274 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
275 
276 #if _LIBCPP_STD_VER >= 14
277 template <>
278 struct _LIBCPP_TEMPLATE_VIS bit_xor<void> {
279   template <class _T1, class _T2>
280   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
281       noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) //
282       -> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) {
283     return std::forward<_T1>(__t) ^ std::forward<_T2>(__u);
284   }
285   typedef void is_transparent;
286 };
287 #endif
288 
289 // Comparison operations
290 
291 #if _LIBCPP_STD_VER >= 14
292 template <class _Tp = void>
293 #else
294 template <class _Tp>
295 #endif
296 struct _LIBCPP_TEMPLATE_VIS equal_to : __binary_function<_Tp, _Tp, bool> {
297   typedef bool __result_type; // used by valarray
298   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
299     return __x == __y;
300   }
301 };
302 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
303 
304 #if _LIBCPP_STD_VER >= 14
305 template <>
306 struct _LIBCPP_TEMPLATE_VIS equal_to<void> {
307   template <class _T1, class _T2>
308   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
309       noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) //
310       -> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) {
311     return std::forward<_T1>(__t) == std::forward<_T2>(__u);
312   }
313   typedef void is_transparent;
314 };
315 #endif
316 
317 // The non-transparent std::equal_to specialization is only equivalent to a raw equality
318 // comparison when we don't perform an implicit conversion when calling it.
319 template <class _Tp>
320 inline const bool __desugars_to_v<__equal_tag, equal_to<_Tp>, _Tp, _Tp> = true;
321 
322 // In the transparent case, we do not enforce that
323 template <class _Tp, class _Up>
324 inline const bool __desugars_to_v<__equal_tag, equal_to<void>, _Tp, _Up> = true;
325 
326 #if _LIBCPP_STD_VER >= 14
327 template <class _Tp = void>
328 #else
329 template <class _Tp>
330 #endif
331 struct _LIBCPP_TEMPLATE_VIS not_equal_to : __binary_function<_Tp, _Tp, bool> {
332   typedef bool __result_type; // used by valarray
333   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
334     return __x != __y;
335   }
336 };
337 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
338 
339 #if _LIBCPP_STD_VER >= 14
340 template <>
341 struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> {
342   template <class _T1, class _T2>
343   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
344       noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) //
345       -> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) {
346     return std::forward<_T1>(__t) != std::forward<_T2>(__u);
347   }
348   typedef void is_transparent;
349 };
350 #endif
351 
352 #if _LIBCPP_STD_VER >= 14
353 template <class _Tp = void>
354 #else
355 template <class _Tp>
356 #endif
357 struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> {
358   typedef bool __result_type; // used by valarray
359   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
360     return __x < __y;
361   }
362 };
363 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
364 
365 template <class _Tp>
366 inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _Tp> = is_integral<_Tp>::value;
367 
368 #if _LIBCPP_STD_VER >= 14
369 template <>
370 struct _LIBCPP_TEMPLATE_VIS less<void> {
371   template <class _T1, class _T2>
372   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
373       noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) //
374       -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) {
375     return std::forward<_T1>(__t) < std::forward<_T2>(__u);
376   }
377   typedef void is_transparent;
378 };
379 
380 template <class _Tp>
381 inline const bool __desugars_to_v<__totally_ordered_less_tag, less<>, _Tp, _Tp> = is_integral<_Tp>::value;
382 #endif
383 
384 #if _LIBCPP_STD_VER >= 14
385 template <class _Tp = void>
386 #else
387 template <class _Tp>
388 #endif
389 struct _LIBCPP_TEMPLATE_VIS less_equal : __binary_function<_Tp, _Tp, bool> {
390   typedef bool __result_type; // used by valarray
391   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
392     return __x <= __y;
393   }
394 };
395 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
396 
397 #if _LIBCPP_STD_VER >= 14
398 template <>
399 struct _LIBCPP_TEMPLATE_VIS less_equal<void> {
400   template <class _T1, class _T2>
401   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
402       noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) //
403       -> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) {
404     return std::forward<_T1>(__t) <= std::forward<_T2>(__u);
405   }
406   typedef void is_transparent;
407 };
408 #endif
409 
410 #if _LIBCPP_STD_VER >= 14
411 template <class _Tp = void>
412 #else
413 template <class _Tp>
414 #endif
415 struct _LIBCPP_TEMPLATE_VIS greater_equal : __binary_function<_Tp, _Tp, bool> {
416   typedef bool __result_type; // used by valarray
417   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
418     return __x >= __y;
419   }
420 };
421 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
422 
423 #if _LIBCPP_STD_VER >= 14
424 template <>
425 struct _LIBCPP_TEMPLATE_VIS greater_equal<void> {
426   template <class _T1, class _T2>
427   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
428       noexcept(noexcept(std::forward<_T1>(__t) >=
429                         std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) {
430     return std::forward<_T1>(__t) >= std::forward<_T2>(__u);
431   }
432   typedef void is_transparent;
433 };
434 #endif
435 
436 #if _LIBCPP_STD_VER >= 14
437 template <class _Tp = void>
438 #else
439 template <class _Tp>
440 #endif
441 struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> {
442   typedef bool __result_type; // used by valarray
443   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
444     return __x > __y;
445   }
446 };
447 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
448 
449 #if _LIBCPP_STD_VER >= 14
450 template <>
451 struct _LIBCPP_TEMPLATE_VIS greater<void> {
452   template <class _T1, class _T2>
453   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
454       noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) //
455       -> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) {
456     return std::forward<_T1>(__t) > std::forward<_T2>(__u);
457   }
458   typedef void is_transparent;
459 };
460 #endif
461 
462 // Logical operations
463 
464 #if _LIBCPP_STD_VER >= 14
465 template <class _Tp = void>
466 #else
467 template <class _Tp>
468 #endif
469 struct _LIBCPP_TEMPLATE_VIS logical_and : __binary_function<_Tp, _Tp, bool> {
470   typedef bool __result_type; // used by valarray
471   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
472     return __x && __y;
473   }
474 };
475 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
476 
477 #if _LIBCPP_STD_VER >= 14
478 template <>
479 struct _LIBCPP_TEMPLATE_VIS logical_and<void> {
480   template <class _T1, class _T2>
481   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
482       noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) //
483       -> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) {
484     return std::forward<_T1>(__t) && std::forward<_T2>(__u);
485   }
486   typedef void is_transparent;
487 };
488 #endif
489 
490 #if _LIBCPP_STD_VER >= 14
491 template <class _Tp = void>
492 #else
493 template <class _Tp>
494 #endif
495 struct _LIBCPP_TEMPLATE_VIS logical_not : __unary_function<_Tp, bool> {
496   typedef bool __result_type; // used by valarray
497   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; }
498 };
499 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
500 
501 #if _LIBCPP_STD_VER >= 14
502 template <>
503 struct _LIBCPP_TEMPLATE_VIS logical_not<void> {
504   template <class _Tp>
505   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
506       noexcept(noexcept(!std::forward<_Tp>(__x))) //
507       -> decltype(!std::forward<_Tp>(__x)) {
508     return !std::forward<_Tp>(__x);
509   }
510   typedef void is_transparent;
511 };
512 #endif
513 
514 #if _LIBCPP_STD_VER >= 14
515 template <class _Tp = void>
516 #else
517 template <class _Tp>
518 #endif
519 struct _LIBCPP_TEMPLATE_VIS logical_or : __binary_function<_Tp, _Tp, bool> {
520   typedef bool __result_type; // used by valarray
521   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
522     return __x || __y;
523   }
524 };
525 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
526 
527 #if _LIBCPP_STD_VER >= 14
528 template <>
529 struct _LIBCPP_TEMPLATE_VIS logical_or<void> {
530   template <class _T1, class _T2>
531   _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
532       noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) //
533       -> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) {
534     return std::forward<_T1>(__t) || std::forward<_T2>(__u);
535   }
536   typedef void is_transparent;
537 };
538 #endif
539 
540 _LIBCPP_END_NAMESPACE_STD
541 
542 #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
543