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