xref: /freebsd-src/contrib/llvm-project/libcxx/include/__functional/operations.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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>
16fe6060f1SDimitry Andric #include <__utility/forward.h>
17fe6060f1SDimitry Andric 
18fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19fe6060f1SDimitry Andric #  pragma GCC system_header
20fe6060f1SDimitry Andric #endif
21fe6060f1SDimitry Andric 
22fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
23fe6060f1SDimitry Andric 
24fe6060f1SDimitry Andric // Arithmetic operations
25fe6060f1SDimitry Andric 
26fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
27fe6060f1SDimitry Andric template <class _Tp = void>
28fe6060f1SDimitry Andric #else
29fe6060f1SDimitry Andric template <class _Tp>
30fe6060f1SDimitry Andric #endif
31fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS plus
3281ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
33fe6060f1SDimitry Andric {
34fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
35*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
36fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
37fe6060f1SDimitry Andric         {return __x + __y;}
38fe6060f1SDimitry Andric };
39*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
40fe6060f1SDimitry Andric 
41fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
42fe6060f1SDimitry Andric template <>
43fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS plus<void>
44fe6060f1SDimitry Andric {
45fe6060f1SDimitry Andric     template <class _T1, class _T2>
46*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
47fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
48349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
49fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
50fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
51fe6060f1SDimitry Andric     typedef void is_transparent;
52fe6060f1SDimitry Andric };
53fe6060f1SDimitry Andric #endif
54fe6060f1SDimitry Andric 
55fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
56fe6060f1SDimitry Andric template <class _Tp = void>
57fe6060f1SDimitry Andric #else
58fe6060f1SDimitry Andric template <class _Tp>
59fe6060f1SDimitry Andric #endif
60fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS minus
6181ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
62fe6060f1SDimitry Andric {
63fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
64*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
65fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
66fe6060f1SDimitry Andric         {return __x - __y;}
67fe6060f1SDimitry Andric };
68*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
69fe6060f1SDimitry Andric 
70fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
71fe6060f1SDimitry Andric template <>
72fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS minus<void>
73fe6060f1SDimitry Andric {
74fe6060f1SDimitry Andric     template <class _T1, class _T2>
75*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
76fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
77349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
78fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
79fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
80fe6060f1SDimitry Andric     typedef void is_transparent;
81fe6060f1SDimitry Andric };
82fe6060f1SDimitry Andric #endif
83fe6060f1SDimitry Andric 
84fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
85fe6060f1SDimitry Andric template <class _Tp = void>
86fe6060f1SDimitry Andric #else
87fe6060f1SDimitry Andric template <class _Tp>
88fe6060f1SDimitry Andric #endif
89fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS multiplies
9081ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
91fe6060f1SDimitry Andric {
92fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
93*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
94fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
95fe6060f1SDimitry Andric         {return __x * __y;}
96fe6060f1SDimitry Andric };
97*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
98fe6060f1SDimitry Andric 
99fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
100fe6060f1SDimitry Andric template <>
101fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS multiplies<void>
102fe6060f1SDimitry Andric {
103fe6060f1SDimitry Andric     template <class _T1, class _T2>
104*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
105fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
106349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
107fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
108fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
109fe6060f1SDimitry Andric     typedef void is_transparent;
110fe6060f1SDimitry Andric };
111fe6060f1SDimitry Andric #endif
112fe6060f1SDimitry Andric 
113fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
114fe6060f1SDimitry Andric template <class _Tp = void>
115fe6060f1SDimitry Andric #else
116fe6060f1SDimitry Andric template <class _Tp>
117fe6060f1SDimitry Andric #endif
118fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS divides
11981ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
120fe6060f1SDimitry Andric {
121fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
122*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
123fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
124fe6060f1SDimitry Andric         {return __x / __y;}
125fe6060f1SDimitry Andric };
126*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
127fe6060f1SDimitry Andric 
128fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
129fe6060f1SDimitry Andric template <>
130fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS divides<void>
131fe6060f1SDimitry Andric {
132fe6060f1SDimitry Andric     template <class _T1, class _T2>
133*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
134fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
135349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
136fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
137fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
138fe6060f1SDimitry Andric     typedef void is_transparent;
139fe6060f1SDimitry Andric };
140fe6060f1SDimitry Andric #endif
141fe6060f1SDimitry Andric 
142fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
143fe6060f1SDimitry Andric template <class _Tp = void>
144fe6060f1SDimitry Andric #else
145fe6060f1SDimitry Andric template <class _Tp>
146fe6060f1SDimitry Andric #endif
147fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS modulus
14881ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
149fe6060f1SDimitry Andric {
150fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
151*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
152fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
153fe6060f1SDimitry Andric         {return __x % __y;}
154fe6060f1SDimitry Andric };
155*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
156fe6060f1SDimitry Andric 
157fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
158fe6060f1SDimitry Andric template <>
159fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS modulus<void>
160fe6060f1SDimitry Andric {
161fe6060f1SDimitry Andric     template <class _T1, class _T2>
162*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
163fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
164349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
165fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
166fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
167fe6060f1SDimitry Andric     typedef void is_transparent;
168fe6060f1SDimitry Andric };
169fe6060f1SDimitry Andric #endif
170fe6060f1SDimitry Andric 
171fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
172fe6060f1SDimitry Andric template <class _Tp = void>
173fe6060f1SDimitry Andric #else
174fe6060f1SDimitry Andric template <class _Tp>
175fe6060f1SDimitry Andric #endif
176fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS negate
17781ad6265SDimitry Andric     : __unary_function<_Tp, _Tp>
178fe6060f1SDimitry Andric {
179fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
180*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
181fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x) const
182fe6060f1SDimitry Andric         {return -__x;}
183fe6060f1SDimitry Andric };
184*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
185fe6060f1SDimitry Andric 
186fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
187fe6060f1SDimitry Andric template <>
188fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS negate<void>
189fe6060f1SDimitry Andric {
190fe6060f1SDimitry Andric     template <class _Tp>
191*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
192fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
193349cc55cSDimitry Andric         noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
194fe6060f1SDimitry Andric         -> decltype(      - _VSTD::forward<_Tp>(__x))
195fe6060f1SDimitry Andric         { return          - _VSTD::forward<_Tp>(__x); }
196fe6060f1SDimitry Andric     typedef void is_transparent;
197fe6060f1SDimitry Andric };
198fe6060f1SDimitry Andric #endif
199fe6060f1SDimitry Andric 
200fe6060f1SDimitry Andric // Bitwise operations
201fe6060f1SDimitry Andric 
202fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
203fe6060f1SDimitry Andric template <class _Tp = void>
204fe6060f1SDimitry Andric #else
205fe6060f1SDimitry Andric template <class _Tp>
206fe6060f1SDimitry Andric #endif
207fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_and
20881ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
209fe6060f1SDimitry Andric {
210fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
211*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
212fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
213fe6060f1SDimitry Andric         {return __x & __y;}
214fe6060f1SDimitry Andric };
215*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
216fe6060f1SDimitry Andric 
217fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
218fe6060f1SDimitry Andric template <>
219fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_and<void>
220fe6060f1SDimitry Andric {
221fe6060f1SDimitry Andric     template <class _T1, class _T2>
222*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
223fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
224349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
225fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
226fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
227fe6060f1SDimitry Andric     typedef void is_transparent;
228fe6060f1SDimitry Andric };
229fe6060f1SDimitry Andric #endif
230fe6060f1SDimitry Andric 
231fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
232fe6060f1SDimitry Andric template <class _Tp = void>
233fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_not
23481ad6265SDimitry Andric     : __unary_function<_Tp, _Tp>
235fe6060f1SDimitry Andric {
236*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
237fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x) const
238fe6060f1SDimitry Andric         {return ~__x;}
239fe6060f1SDimitry Andric };
240*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
241fe6060f1SDimitry Andric 
242fe6060f1SDimitry Andric template <>
243fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_not<void>
244fe6060f1SDimitry Andric {
245fe6060f1SDimitry Andric     template <class _Tp>
246*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
247fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
248349cc55cSDimitry Andric         noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
249fe6060f1SDimitry Andric         -> decltype(      ~_VSTD::forward<_Tp>(__x))
250fe6060f1SDimitry Andric         { return          ~_VSTD::forward<_Tp>(__x); }
251fe6060f1SDimitry Andric     typedef void is_transparent;
252fe6060f1SDimitry Andric };
253fe6060f1SDimitry Andric #endif
254fe6060f1SDimitry Andric 
255fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
256fe6060f1SDimitry Andric template <class _Tp = void>
257fe6060f1SDimitry Andric #else
258fe6060f1SDimitry Andric template <class _Tp>
259fe6060f1SDimitry Andric #endif
260fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_or
26181ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
262fe6060f1SDimitry Andric {
263fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
264*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
265fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
266fe6060f1SDimitry Andric         {return __x | __y;}
267fe6060f1SDimitry Andric };
268*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
269fe6060f1SDimitry Andric 
270fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
271fe6060f1SDimitry Andric template <>
272fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_or<void>
273fe6060f1SDimitry Andric {
274fe6060f1SDimitry Andric     template <class _T1, class _T2>
275*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
276fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
277349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
278fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
279fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
280fe6060f1SDimitry Andric     typedef void is_transparent;
281fe6060f1SDimitry Andric };
282fe6060f1SDimitry Andric #endif
283fe6060f1SDimitry Andric 
284fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
285fe6060f1SDimitry Andric template <class _Tp = void>
286fe6060f1SDimitry Andric #else
287fe6060f1SDimitry Andric template <class _Tp>
288fe6060f1SDimitry Andric #endif
289fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_xor
29081ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, _Tp>
291fe6060f1SDimitry Andric {
292fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
293*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
294fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
295fe6060f1SDimitry Andric         {return __x ^ __y;}
296fe6060f1SDimitry Andric };
297*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
298fe6060f1SDimitry Andric 
299fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
300fe6060f1SDimitry Andric template <>
301fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
302fe6060f1SDimitry Andric {
303fe6060f1SDimitry Andric     template <class _T1, class _T2>
304*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
305fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
306349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
307fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
308fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
309fe6060f1SDimitry Andric     typedef void is_transparent;
310fe6060f1SDimitry Andric };
311fe6060f1SDimitry Andric #endif
312fe6060f1SDimitry Andric 
313fe6060f1SDimitry Andric // Comparison operations
314fe6060f1SDimitry Andric 
315fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
316fe6060f1SDimitry Andric template <class _Tp = void>
317fe6060f1SDimitry Andric #else
318fe6060f1SDimitry Andric template <class _Tp>
319fe6060f1SDimitry Andric #endif
320fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS equal_to
32181ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
322fe6060f1SDimitry Andric {
323fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
324*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
325fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
326fe6060f1SDimitry Andric         {return __x == __y;}
327fe6060f1SDimitry Andric };
328*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
329fe6060f1SDimitry Andric 
330fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
331fe6060f1SDimitry Andric template <>
332fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS equal_to<void>
333fe6060f1SDimitry Andric {
334fe6060f1SDimitry Andric     template <class _T1, class _T2>
335*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
336fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
337349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
338fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
339fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
340fe6060f1SDimitry Andric     typedef void is_transparent;
341fe6060f1SDimitry Andric };
342fe6060f1SDimitry Andric #endif
343fe6060f1SDimitry Andric 
344fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
345fe6060f1SDimitry Andric template <class _Tp = void>
346fe6060f1SDimitry Andric #else
347fe6060f1SDimitry Andric template <class _Tp>
348fe6060f1SDimitry Andric #endif
349fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS not_equal_to
35081ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
351fe6060f1SDimitry Andric {
352fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
353*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
354fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
355fe6060f1SDimitry Andric         {return __x != __y;}
356fe6060f1SDimitry Andric };
357*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
358fe6060f1SDimitry Andric 
359fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
360fe6060f1SDimitry Andric template <>
361fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
362fe6060f1SDimitry Andric {
363fe6060f1SDimitry Andric     template <class _T1, class _T2>
364*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
365fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
366349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
367fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
368fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
369fe6060f1SDimitry Andric     typedef void is_transparent;
370fe6060f1SDimitry Andric };
371fe6060f1SDimitry Andric #endif
372fe6060f1SDimitry Andric 
373fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
374fe6060f1SDimitry Andric template <class _Tp = void>
375fe6060f1SDimitry Andric #else
376fe6060f1SDimitry Andric template <class _Tp>
377fe6060f1SDimitry Andric #endif
378fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less
37981ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
380fe6060f1SDimitry Andric {
381fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
382*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
383fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
384fe6060f1SDimitry Andric         {return __x < __y;}
385fe6060f1SDimitry Andric };
386*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
387fe6060f1SDimitry Andric 
388fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
389fe6060f1SDimitry Andric template <>
390fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less<void>
391fe6060f1SDimitry Andric {
392fe6060f1SDimitry Andric     template <class _T1, class _T2>
393*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
394fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
395349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
396fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
397fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
398fe6060f1SDimitry Andric     typedef void is_transparent;
399fe6060f1SDimitry Andric };
400fe6060f1SDimitry Andric #endif
401fe6060f1SDimitry Andric 
402fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
403fe6060f1SDimitry Andric template <class _Tp = void>
404fe6060f1SDimitry Andric #else
405fe6060f1SDimitry Andric template <class _Tp>
406fe6060f1SDimitry Andric #endif
407fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less_equal
40881ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
409fe6060f1SDimitry Andric {
410fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
411*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
412fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
413fe6060f1SDimitry Andric         {return __x <= __y;}
414fe6060f1SDimitry Andric };
415*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
416fe6060f1SDimitry Andric 
417fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
418fe6060f1SDimitry Andric template <>
419fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less_equal<void>
420fe6060f1SDimitry Andric {
421fe6060f1SDimitry Andric     template <class _T1, class _T2>
422*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
423fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
424349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
425fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
426fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
427fe6060f1SDimitry Andric     typedef void is_transparent;
428fe6060f1SDimitry Andric };
429fe6060f1SDimitry Andric #endif
430fe6060f1SDimitry Andric 
431fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
432fe6060f1SDimitry Andric template <class _Tp = void>
433fe6060f1SDimitry Andric #else
434fe6060f1SDimitry Andric template <class _Tp>
435fe6060f1SDimitry Andric #endif
436fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater_equal
43781ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
438fe6060f1SDimitry Andric {
439fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
440*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
441fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
442fe6060f1SDimitry Andric         {return __x >= __y;}
443fe6060f1SDimitry Andric };
444*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
445fe6060f1SDimitry Andric 
446fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
447fe6060f1SDimitry Andric template <>
448fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
449fe6060f1SDimitry Andric {
450fe6060f1SDimitry Andric     template <class _T1, class _T2>
451*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
452fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
453349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
454fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
455fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
456fe6060f1SDimitry Andric     typedef void is_transparent;
457fe6060f1SDimitry Andric };
458fe6060f1SDimitry Andric #endif
459fe6060f1SDimitry Andric 
460fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
461fe6060f1SDimitry Andric template <class _Tp = void>
462fe6060f1SDimitry Andric #else
463fe6060f1SDimitry Andric template <class _Tp>
464fe6060f1SDimitry Andric #endif
465fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater
46681ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
467fe6060f1SDimitry Andric {
468fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
469*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
470fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
471fe6060f1SDimitry Andric         {return __x > __y;}
472fe6060f1SDimitry Andric };
473*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
474fe6060f1SDimitry Andric 
475fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
476fe6060f1SDimitry Andric template <>
477fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater<void>
478fe6060f1SDimitry Andric {
479fe6060f1SDimitry Andric     template <class _T1, class _T2>
480*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
481fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
482349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
483fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
484fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
485fe6060f1SDimitry Andric     typedef void is_transparent;
486fe6060f1SDimitry Andric };
487fe6060f1SDimitry Andric #endif
488fe6060f1SDimitry Andric 
489fe6060f1SDimitry Andric // Logical operations
490fe6060f1SDimitry Andric 
491fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
492fe6060f1SDimitry Andric template <class _Tp = void>
493fe6060f1SDimitry Andric #else
494fe6060f1SDimitry Andric template <class _Tp>
495fe6060f1SDimitry Andric #endif
496fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_and
49781ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
498fe6060f1SDimitry Andric {
499fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
500*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
501fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
502fe6060f1SDimitry Andric         {return __x && __y;}
503fe6060f1SDimitry Andric };
504*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
505fe6060f1SDimitry Andric 
506fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
507fe6060f1SDimitry Andric template <>
508fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_and<void>
509fe6060f1SDimitry Andric {
510fe6060f1SDimitry Andric     template <class _T1, class _T2>
511*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
512fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
513349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
514fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
515fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
516fe6060f1SDimitry Andric     typedef void is_transparent;
517fe6060f1SDimitry Andric };
518fe6060f1SDimitry Andric #endif
519fe6060f1SDimitry Andric 
520fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
521fe6060f1SDimitry Andric template <class _Tp = void>
522fe6060f1SDimitry Andric #else
523fe6060f1SDimitry Andric template <class _Tp>
524fe6060f1SDimitry Andric #endif
525fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_not
52681ad6265SDimitry Andric     : __unary_function<_Tp, bool>
527fe6060f1SDimitry Andric {
528fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
529*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
530fe6060f1SDimitry Andric     bool operator()(const _Tp& __x) const
531fe6060f1SDimitry Andric         {return !__x;}
532fe6060f1SDimitry Andric };
533*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
534fe6060f1SDimitry Andric 
535fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
536fe6060f1SDimitry Andric template <>
537fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_not<void>
538fe6060f1SDimitry Andric {
539fe6060f1SDimitry Andric     template <class _Tp>
540*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
541fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
542349cc55cSDimitry Andric         noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
543fe6060f1SDimitry Andric         -> decltype(      !_VSTD::forward<_Tp>(__x))
544fe6060f1SDimitry Andric         { return          !_VSTD::forward<_Tp>(__x); }
545fe6060f1SDimitry Andric     typedef void is_transparent;
546fe6060f1SDimitry Andric };
547fe6060f1SDimitry Andric #endif
548fe6060f1SDimitry Andric 
549fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
550fe6060f1SDimitry Andric template <class _Tp = void>
551fe6060f1SDimitry Andric #else
552fe6060f1SDimitry Andric template <class _Tp>
553fe6060f1SDimitry Andric #endif
554fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_or
55581ad6265SDimitry Andric     : __binary_function<_Tp, _Tp, bool>
556fe6060f1SDimitry Andric {
557fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
558*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
559fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
560fe6060f1SDimitry Andric         {return __x || __y;}
561fe6060f1SDimitry Andric };
562*bdd1243dSDimitry Andric _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
563fe6060f1SDimitry Andric 
564fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
565fe6060f1SDimitry Andric template <>
566fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_or<void>
567fe6060f1SDimitry Andric {
568fe6060f1SDimitry Andric     template <class _T1, class _T2>
569*bdd1243dSDimitry Andric     _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
570fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
571349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
572fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
573fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
574fe6060f1SDimitry Andric     typedef void is_transparent;
575fe6060f1SDimitry Andric };
576fe6060f1SDimitry Andric #endif
577fe6060f1SDimitry Andric 
578fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
579fe6060f1SDimitry Andric 
580fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
581