xref: /freebsd/contrib/llvm-project/libcxx/include/__functional/operations.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1fe6060f1SDimitry Andric // -*- C++ -*-
2fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
3fe6060f1SDimitry Andric //
4fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
6fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7fe6060f1SDimitry Andric //
8fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
9fe6060f1SDimitry Andric 
10fe6060f1SDimitry Andric #ifndef _LIBCPP___FUNCTIONAL_OPERATIONS_H
11fe6060f1SDimitry Andric #define _LIBCPP___FUNCTIONAL_OPERATIONS_H
12fe6060f1SDimitry Andric 
13fe6060f1SDimitry Andric #include <__config>
14fe6060f1SDimitry Andric #include <__functional/binary_function.h>
15fe6060f1SDimitry Andric #include <__functional/unary_function.h>
16*06c3fb27SDimitry Andric #include <__type_traits/integral_constant.h>
17*06c3fb27SDimitry Andric #include <__type_traits/operation_traits.h>
18*06c3fb27SDimitry Andric #include <__type_traits/predicate_traits.h>
19fe6060f1SDimitry Andric #include <__utility/forward.h>
20fe6060f1SDimitry Andric 
21fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22fe6060f1SDimitry Andric #  pragma GCC system_header
23fe6060f1SDimitry Andric #endif
24fe6060f1SDimitry Andric 
25fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
26fe6060f1SDimitry Andric 
27fe6060f1SDimitry Andric // Arithmetic operations
28fe6060f1SDimitry Andric 
29*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
30fe6060f1SDimitry Andric template <class _Tp = void>
31fe6060f1SDimitry Andric #else
32fe6060f1SDimitry Andric template <class _Tp>
33fe6060f1SDimitry Andric #endif
34fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS plus
3581ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
36fe6060f1SDimitry Andric {
37fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
38bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
39fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
40fe6060f1SDimitry Andric         {return __x + __y;}
41fe6060f1SDimitry Andric };
42bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
43fe6060f1SDimitry Andric 
44*06c3fb27SDimitry Andric template <class _Tp>
45*06c3fb27SDimitry Andric struct __is_trivial_plus_operation<plus<_Tp>, _Tp, _Tp> : true_type {};
46*06c3fb27SDimitry Andric 
47*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
48*06c3fb27SDimitry Andric template <class _Tp, class _Up>
49*06c3fb27SDimitry Andric struct __is_trivial_plus_operation<plus<>, _Tp, _Up> : true_type {};
50*06c3fb27SDimitry Andric #endif
51*06c3fb27SDimitry Andric 
52*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
53fe6060f1SDimitry Andric template <>
54fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS plus<void>
55fe6060f1SDimitry Andric {
56fe6060f1SDimitry Andric     template <class _T1, class _T2>
57bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
58fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
59349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
60fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
61fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
62fe6060f1SDimitry Andric     typedef void is_transparent;
63fe6060f1SDimitry Andric };
64fe6060f1SDimitry Andric #endif
65fe6060f1SDimitry Andric 
66*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
67fe6060f1SDimitry Andric template <class _Tp = void>
68fe6060f1SDimitry Andric #else
69fe6060f1SDimitry Andric template <class _Tp>
70fe6060f1SDimitry Andric #endif
71fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS minus
7281ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
73fe6060f1SDimitry Andric {
74fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
75bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
76fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
77fe6060f1SDimitry Andric         {return __x - __y;}
78fe6060f1SDimitry Andric };
79bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
80fe6060f1SDimitry Andric 
81*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
82fe6060f1SDimitry Andric template <>
83fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS minus<void>
84fe6060f1SDimitry Andric {
85fe6060f1SDimitry Andric     template <class _T1, class _T2>
86bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
87fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
88349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
89fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
90fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
91fe6060f1SDimitry Andric     typedef void is_transparent;
92fe6060f1SDimitry Andric };
93fe6060f1SDimitry Andric #endif
94fe6060f1SDimitry Andric 
95*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
96fe6060f1SDimitry Andric template <class _Tp = void>
97fe6060f1SDimitry Andric #else
98fe6060f1SDimitry Andric template <class _Tp>
99fe6060f1SDimitry Andric #endif
100fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS multiplies
10181ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
102fe6060f1SDimitry Andric {
103fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
104bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
105fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
106fe6060f1SDimitry Andric         {return __x * __y;}
107fe6060f1SDimitry Andric };
108bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
109fe6060f1SDimitry Andric 
110*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
111fe6060f1SDimitry Andric template <>
112fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS multiplies<void>
113fe6060f1SDimitry Andric {
114fe6060f1SDimitry Andric     template <class _T1, class _T2>
115bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
116fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
117349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
118fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
119fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
120fe6060f1SDimitry Andric     typedef void is_transparent;
121fe6060f1SDimitry Andric };
122fe6060f1SDimitry Andric #endif
123fe6060f1SDimitry Andric 
124*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
125fe6060f1SDimitry Andric template <class _Tp = void>
126fe6060f1SDimitry Andric #else
127fe6060f1SDimitry Andric template <class _Tp>
128fe6060f1SDimitry Andric #endif
129fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS divides
13081ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
131fe6060f1SDimitry Andric {
132fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
133bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
134fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
135fe6060f1SDimitry Andric         {return __x / __y;}
136fe6060f1SDimitry Andric };
137bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
138fe6060f1SDimitry Andric 
139*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
140fe6060f1SDimitry Andric template <>
141fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS divides<void>
142fe6060f1SDimitry Andric {
143fe6060f1SDimitry Andric     template <class _T1, class _T2>
144bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
145fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
146349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
147fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
148fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
149fe6060f1SDimitry Andric     typedef void is_transparent;
150fe6060f1SDimitry Andric };
151fe6060f1SDimitry Andric #endif
152fe6060f1SDimitry Andric 
153*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
154fe6060f1SDimitry Andric template <class _Tp = void>
155fe6060f1SDimitry Andric #else
156fe6060f1SDimitry Andric template <class _Tp>
157fe6060f1SDimitry Andric #endif
158fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS modulus
15981ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
160fe6060f1SDimitry Andric {
161fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
162bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
163fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
164fe6060f1SDimitry Andric         {return __x % __y;}
165fe6060f1SDimitry Andric };
166bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
167fe6060f1SDimitry Andric 
168*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
169fe6060f1SDimitry Andric template <>
170fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS modulus<void>
171fe6060f1SDimitry Andric {
172fe6060f1SDimitry Andric     template <class _T1, class _T2>
173bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
174fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
175349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
176fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
177fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
178fe6060f1SDimitry Andric     typedef void is_transparent;
179fe6060f1SDimitry Andric };
180fe6060f1SDimitry Andric #endif
181fe6060f1SDimitry Andric 
182*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
183fe6060f1SDimitry Andric template <class _Tp = void>
184fe6060f1SDimitry Andric #else
185fe6060f1SDimitry Andric template <class _Tp>
186fe6060f1SDimitry Andric #endif
187fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS negate
18881ad6265SDimitry Andric     : __unary_function<_Tp, _Tp>
189fe6060f1SDimitry Andric {
190fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
191bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
192fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x) const
193fe6060f1SDimitry Andric         {return -__x;}
194fe6060f1SDimitry Andric };
195bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
196fe6060f1SDimitry Andric 
197*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
198fe6060f1SDimitry Andric template <>
199fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS negate<void>
200fe6060f1SDimitry Andric {
201fe6060f1SDimitry Andric     template <class _Tp>
202bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
203fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
204349cc55cSDimitry Andric         noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
205fe6060f1SDimitry Andric         -> decltype(      - _VSTD::forward<_Tp>(__x))
206fe6060f1SDimitry Andric         { return          - _VSTD::forward<_Tp>(__x); }
207fe6060f1SDimitry Andric     typedef void is_transparent;
208fe6060f1SDimitry Andric };
209fe6060f1SDimitry Andric #endif
210fe6060f1SDimitry Andric 
211fe6060f1SDimitry Andric // Bitwise operations
212fe6060f1SDimitry Andric 
213*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
214fe6060f1SDimitry Andric template <class _Tp = void>
215fe6060f1SDimitry Andric #else
216fe6060f1SDimitry Andric template <class _Tp>
217fe6060f1SDimitry Andric #endif
218fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_and
21981ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
220fe6060f1SDimitry Andric {
221fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
222bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
223fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
224fe6060f1SDimitry Andric         {return __x & __y;}
225fe6060f1SDimitry Andric };
226bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
227fe6060f1SDimitry Andric 
228*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
229fe6060f1SDimitry Andric template <>
230fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_and<void>
231fe6060f1SDimitry Andric {
232fe6060f1SDimitry Andric     template <class _T1, class _T2>
233bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
234fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
235349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
236fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
237fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
238fe6060f1SDimitry Andric     typedef void is_transparent;
239fe6060f1SDimitry Andric };
240fe6060f1SDimitry Andric #endif
241fe6060f1SDimitry Andric 
242*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
243fe6060f1SDimitry Andric template <class _Tp = void>
244fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_not
24581ad6265SDimitry Andric     : __unary_function<_Tp, _Tp>
246fe6060f1SDimitry Andric {
247bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
248fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x) const
249fe6060f1SDimitry Andric         {return ~__x;}
250fe6060f1SDimitry Andric };
251bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
252fe6060f1SDimitry Andric 
253fe6060f1SDimitry Andric template <>
254fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_not<void>
255fe6060f1SDimitry Andric {
256fe6060f1SDimitry Andric     template <class _Tp>
257bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
258fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
259349cc55cSDimitry Andric         noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
260fe6060f1SDimitry Andric         -> decltype(      ~_VSTD::forward<_Tp>(__x))
261fe6060f1SDimitry Andric         { return          ~_VSTD::forward<_Tp>(__x); }
262fe6060f1SDimitry Andric     typedef void is_transparent;
263fe6060f1SDimitry Andric };
264fe6060f1SDimitry Andric #endif
265fe6060f1SDimitry Andric 
266*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
267fe6060f1SDimitry Andric template <class _Tp = void>
268fe6060f1SDimitry Andric #else
269fe6060f1SDimitry Andric template <class _Tp>
270fe6060f1SDimitry Andric #endif
271fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_or
27281ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
273fe6060f1SDimitry Andric {
274fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
275bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
276fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
277fe6060f1SDimitry Andric         {return __x | __y;}
278fe6060f1SDimitry Andric };
279bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
280fe6060f1SDimitry Andric 
281*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
282fe6060f1SDimitry Andric template <>
283fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_or<void>
284fe6060f1SDimitry Andric {
285fe6060f1SDimitry Andric     template <class _T1, class _T2>
286bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
287fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
288349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
289fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
290fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
291fe6060f1SDimitry Andric     typedef void is_transparent;
292fe6060f1SDimitry Andric };
293fe6060f1SDimitry Andric #endif
294fe6060f1SDimitry Andric 
295*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
296fe6060f1SDimitry Andric template <class _Tp = void>
297fe6060f1SDimitry Andric #else
298fe6060f1SDimitry Andric template <class _Tp>
299fe6060f1SDimitry Andric #endif
300fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_xor
30181ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
302fe6060f1SDimitry Andric {
303fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
304bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
305fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
306fe6060f1SDimitry Andric         {return __x ^ __y;}
307fe6060f1SDimitry Andric };
308bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
309fe6060f1SDimitry Andric 
310*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
311fe6060f1SDimitry Andric template <>
312fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
313fe6060f1SDimitry Andric {
314fe6060f1SDimitry Andric     template <class _T1, class _T2>
315bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
316fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
317349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
318fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
319fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
320fe6060f1SDimitry Andric     typedef void is_transparent;
321fe6060f1SDimitry Andric };
322fe6060f1SDimitry Andric #endif
323fe6060f1SDimitry Andric 
324fe6060f1SDimitry Andric // Comparison operations
325fe6060f1SDimitry Andric 
326*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
327fe6060f1SDimitry Andric template <class _Tp = void>
328fe6060f1SDimitry Andric #else
329fe6060f1SDimitry Andric template <class _Tp>
330fe6060f1SDimitry Andric #endif
331fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS equal_to
33281ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
333fe6060f1SDimitry Andric {
334fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
335bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
336fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
337fe6060f1SDimitry Andric         {return __x == __y;}
338fe6060f1SDimitry Andric };
339bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
340fe6060f1SDimitry Andric 
341*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
342fe6060f1SDimitry Andric template <>
343fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS equal_to<void>
344fe6060f1SDimitry Andric {
345fe6060f1SDimitry Andric     template <class _T1, class _T2>
346bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
347fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
348349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
349fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
350fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
351fe6060f1SDimitry Andric     typedef void is_transparent;
352fe6060f1SDimitry Andric };
353fe6060f1SDimitry Andric #endif
354fe6060f1SDimitry Andric 
355*06c3fb27SDimitry Andric template <class _Tp>
356*06c3fb27SDimitry Andric struct __is_trivial_equality_predicate<equal_to<_Tp>, _Tp, _Tp> : true_type {};
357*06c3fb27SDimitry Andric 
358*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
359*06c3fb27SDimitry Andric template <class _Tp>
360*06c3fb27SDimitry Andric struct __is_trivial_equality_predicate<equal_to<>, _Tp, _Tp> : true_type {};
361*06c3fb27SDimitry Andric #endif
362*06c3fb27SDimitry Andric 
363*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
364fe6060f1SDimitry Andric template <class _Tp = void>
365fe6060f1SDimitry Andric #else
366fe6060f1SDimitry Andric template <class _Tp>
367fe6060f1SDimitry Andric #endif
368fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS not_equal_to
36981ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
370fe6060f1SDimitry Andric {
371fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
372bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
373fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
374fe6060f1SDimitry Andric         {return __x != __y;}
375fe6060f1SDimitry Andric };
376bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
377fe6060f1SDimitry Andric 
378*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
379fe6060f1SDimitry Andric template <>
380fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
381fe6060f1SDimitry Andric {
382fe6060f1SDimitry Andric     template <class _T1, class _T2>
383bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
384fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
385349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
386fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
387fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
388fe6060f1SDimitry Andric     typedef void is_transparent;
389fe6060f1SDimitry Andric };
390fe6060f1SDimitry Andric #endif
391fe6060f1SDimitry Andric 
392*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
393fe6060f1SDimitry Andric template <class _Tp = void>
394fe6060f1SDimitry Andric #else
395fe6060f1SDimitry Andric template <class _Tp>
396fe6060f1SDimitry Andric #endif
397fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less
39881ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
399fe6060f1SDimitry Andric {
400fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
401bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
402fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
403fe6060f1SDimitry Andric         {return __x < __y;}
404fe6060f1SDimitry Andric };
405bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
406fe6060f1SDimitry Andric 
407*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
408fe6060f1SDimitry Andric template <>
409fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less<void>
410fe6060f1SDimitry Andric {
411fe6060f1SDimitry Andric     template <class _T1, class _T2>
412bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
413fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
414349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
415fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
416fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
417fe6060f1SDimitry Andric     typedef void is_transparent;
418fe6060f1SDimitry Andric };
419fe6060f1SDimitry Andric #endif
420fe6060f1SDimitry Andric 
421*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
422fe6060f1SDimitry Andric template <class _Tp = void>
423fe6060f1SDimitry Andric #else
424fe6060f1SDimitry Andric template <class _Tp>
425fe6060f1SDimitry Andric #endif
426fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less_equal
42781ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
428fe6060f1SDimitry Andric {
429fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
430bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
431fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
432fe6060f1SDimitry Andric         {return __x <= __y;}
433fe6060f1SDimitry Andric };
434bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
435fe6060f1SDimitry Andric 
436*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
437fe6060f1SDimitry Andric template <>
438fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less_equal<void>
439fe6060f1SDimitry Andric {
440fe6060f1SDimitry Andric     template <class _T1, class _T2>
441bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
442fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
443349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
444fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
445fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
446fe6060f1SDimitry Andric     typedef void is_transparent;
447fe6060f1SDimitry Andric };
448fe6060f1SDimitry Andric #endif
449fe6060f1SDimitry Andric 
450*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
451fe6060f1SDimitry Andric template <class _Tp = void>
452fe6060f1SDimitry Andric #else
453fe6060f1SDimitry Andric template <class _Tp>
454fe6060f1SDimitry Andric #endif
455fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater_equal
45681ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
457fe6060f1SDimitry Andric {
458fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
459bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
460fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
461fe6060f1SDimitry Andric         {return __x >= __y;}
462fe6060f1SDimitry Andric };
463bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
464fe6060f1SDimitry Andric 
465*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
466fe6060f1SDimitry Andric template <>
467fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
468fe6060f1SDimitry Andric {
469fe6060f1SDimitry Andric     template <class _T1, class _T2>
470bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
471fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
472349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
473fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
474fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
475fe6060f1SDimitry Andric     typedef void is_transparent;
476fe6060f1SDimitry Andric };
477fe6060f1SDimitry Andric #endif
478fe6060f1SDimitry Andric 
479*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
480fe6060f1SDimitry Andric template <class _Tp = void>
481fe6060f1SDimitry Andric #else
482fe6060f1SDimitry Andric template <class _Tp>
483fe6060f1SDimitry Andric #endif
484fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater
48581ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
486fe6060f1SDimitry Andric {
487fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
488bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
489fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
490fe6060f1SDimitry Andric         {return __x > __y;}
491fe6060f1SDimitry Andric };
492bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
493fe6060f1SDimitry Andric 
494*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
495fe6060f1SDimitry Andric template <>
496fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater<void>
497fe6060f1SDimitry Andric {
498fe6060f1SDimitry Andric     template <class _T1, class _T2>
499bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
500fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
501349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
502fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
503fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
504fe6060f1SDimitry Andric     typedef void is_transparent;
505fe6060f1SDimitry Andric };
506fe6060f1SDimitry Andric #endif
507fe6060f1SDimitry Andric 
508fe6060f1SDimitry Andric // Logical operations
509fe6060f1SDimitry Andric 
510*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
511fe6060f1SDimitry Andric template <class _Tp = void>
512fe6060f1SDimitry Andric #else
513fe6060f1SDimitry Andric template <class _Tp>
514fe6060f1SDimitry Andric #endif
515fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_and
51681ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
517fe6060f1SDimitry Andric {
518fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
519bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
520fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
521fe6060f1SDimitry Andric         {return __x && __y;}
522fe6060f1SDimitry Andric };
523bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
524fe6060f1SDimitry Andric 
525*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
526fe6060f1SDimitry Andric template <>
527fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_and<void>
528fe6060f1SDimitry Andric {
529fe6060f1SDimitry Andric     template <class _T1, class _T2>
530bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
531fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
532349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
533fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
534fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
535fe6060f1SDimitry Andric     typedef void is_transparent;
536fe6060f1SDimitry Andric };
537fe6060f1SDimitry Andric #endif
538fe6060f1SDimitry Andric 
539*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
540fe6060f1SDimitry Andric template <class _Tp = void>
541fe6060f1SDimitry Andric #else
542fe6060f1SDimitry Andric template <class _Tp>
543fe6060f1SDimitry Andric #endif
544fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_not
54581ad6265SDimitry Andric     : __unary_function<_Tp, bool>
546fe6060f1SDimitry Andric {
547fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
548bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
549fe6060f1SDimitry Andric     bool operator()(const _Tp& __x) const
550fe6060f1SDimitry Andric         {return !__x;}
551fe6060f1SDimitry Andric };
552bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
553fe6060f1SDimitry Andric 
554*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
555fe6060f1SDimitry Andric template <>
556fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_not<void>
557fe6060f1SDimitry Andric {
558fe6060f1SDimitry Andric     template <class _Tp>
559bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
560fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
561349cc55cSDimitry Andric         noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
562fe6060f1SDimitry Andric         -> decltype(      !_VSTD::forward<_Tp>(__x))
563fe6060f1SDimitry Andric         { return          !_VSTD::forward<_Tp>(__x); }
564fe6060f1SDimitry Andric     typedef void is_transparent;
565fe6060f1SDimitry Andric };
566fe6060f1SDimitry Andric #endif
567fe6060f1SDimitry Andric 
568*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
569fe6060f1SDimitry Andric template <class _Tp = void>
570fe6060f1SDimitry Andric #else
571fe6060f1SDimitry Andric template <class _Tp>
572fe6060f1SDimitry Andric #endif
573fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_or
57481ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
575fe6060f1SDimitry Andric {
576fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
577bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
578fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
579fe6060f1SDimitry Andric         {return __x || __y;}
580fe6060f1SDimitry Andric };
581bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
582fe6060f1SDimitry Andric 
583*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 14
584fe6060f1SDimitry Andric template <>
585fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_or<void>
586fe6060f1SDimitry Andric {
587fe6060f1SDimitry Andric     template <class _T1, class _T2>
588bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
589fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
590349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
591fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
592fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
593fe6060f1SDimitry Andric     typedef void is_transparent;
594fe6060f1SDimitry Andric };
595fe6060f1SDimitry Andric #endif
596fe6060f1SDimitry Andric 
597fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
598fe6060f1SDimitry Andric 
599fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
600