xref: /freebsd/contrib/llvm-project/libcxx/include/__functional/operations.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
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 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
27fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
28fe6060f1SDimitry Andric template <class _Tp = void>
29fe6060f1SDimitry Andric #else
30fe6060f1SDimitry Andric template <class _Tp>
31fe6060f1SDimitry Andric #endif
32fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS plus
33fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
34fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
35fe6060f1SDimitry Andric #endif
36fe6060f1SDimitry Andric {
37fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
38fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
39fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
40fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
41fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
42fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
43fe6060f1SDimitry Andric #endif
44fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
45fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
46fe6060f1SDimitry Andric         {return __x + __y;}
47fe6060f1SDimitry Andric };
48fe6060f1SDimitry Andric 
49fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
50fe6060f1SDimitry Andric template <>
51fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS plus<void>
52fe6060f1SDimitry Andric {
53fe6060f1SDimitry Andric     template <class _T1, class _T2>
54fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
55fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
56*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
57fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
58fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
59fe6060f1SDimitry Andric     typedef void is_transparent;
60fe6060f1SDimitry Andric };
61fe6060f1SDimitry Andric #endif
62fe6060f1SDimitry Andric 
63fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
64fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
65fe6060f1SDimitry Andric template <class _Tp = void>
66fe6060f1SDimitry Andric #else
67fe6060f1SDimitry Andric template <class _Tp>
68fe6060f1SDimitry Andric #endif
69fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS minus
70fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
71fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
72fe6060f1SDimitry Andric #endif
73fe6060f1SDimitry Andric {
74fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
75fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
76fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
77fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
78fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
79fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
80fe6060f1SDimitry Andric #endif
81fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
82fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
83fe6060f1SDimitry Andric         {return __x - __y;}
84fe6060f1SDimitry Andric };
85fe6060f1SDimitry Andric 
86fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
87fe6060f1SDimitry Andric template <>
88fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS minus<void>
89fe6060f1SDimitry Andric {
90fe6060f1SDimitry Andric     template <class _T1, class _T2>
91fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
92fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
93*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
94fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
95fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
96fe6060f1SDimitry Andric     typedef void is_transparent;
97fe6060f1SDimitry Andric };
98fe6060f1SDimitry Andric #endif
99fe6060f1SDimitry Andric 
100fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
101fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
102fe6060f1SDimitry Andric template <class _Tp = void>
103fe6060f1SDimitry Andric #else
104fe6060f1SDimitry Andric template <class _Tp>
105fe6060f1SDimitry Andric #endif
106fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS multiplies
107fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
108fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
109fe6060f1SDimitry Andric #endif
110fe6060f1SDimitry Andric {
111fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
112fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
113fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
114fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
115fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
116fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
117fe6060f1SDimitry Andric #endif
118fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
119fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
120fe6060f1SDimitry Andric         {return __x * __y;}
121fe6060f1SDimitry Andric };
122fe6060f1SDimitry Andric 
123fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
124fe6060f1SDimitry Andric template <>
125fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS multiplies<void>
126fe6060f1SDimitry Andric {
127fe6060f1SDimitry Andric     template <class _T1, class _T2>
128fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
129fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
130*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
131fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
132fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
133fe6060f1SDimitry Andric     typedef void is_transparent;
134fe6060f1SDimitry Andric };
135fe6060f1SDimitry Andric #endif
136fe6060f1SDimitry Andric 
137fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
138fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
139fe6060f1SDimitry Andric template <class _Tp = void>
140fe6060f1SDimitry Andric #else
141fe6060f1SDimitry Andric template <class _Tp>
142fe6060f1SDimitry Andric #endif
143fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS divides
144fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
145fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
146fe6060f1SDimitry Andric #endif
147fe6060f1SDimitry Andric {
148fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
149fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
150fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
151fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
152fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
153fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
154fe6060f1SDimitry Andric #endif
155fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
156fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
157fe6060f1SDimitry Andric         {return __x / __y;}
158fe6060f1SDimitry Andric };
159fe6060f1SDimitry Andric 
160fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
161fe6060f1SDimitry Andric template <>
162fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS divides<void>
163fe6060f1SDimitry Andric {
164fe6060f1SDimitry Andric     template <class _T1, class _T2>
165fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
166fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
167*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
168fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
169fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
170fe6060f1SDimitry Andric     typedef void is_transparent;
171fe6060f1SDimitry Andric };
172fe6060f1SDimitry Andric #endif
173fe6060f1SDimitry Andric 
174fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
175fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
176fe6060f1SDimitry Andric template <class _Tp = void>
177fe6060f1SDimitry Andric #else
178fe6060f1SDimitry Andric template <class _Tp>
179fe6060f1SDimitry Andric #endif
180fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS modulus
181fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
182fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
183fe6060f1SDimitry Andric #endif
184fe6060f1SDimitry Andric {
185fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
186fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
187fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
188fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
189fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
190fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
191fe6060f1SDimitry Andric #endif
192fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
193fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
194fe6060f1SDimitry Andric         {return __x % __y;}
195fe6060f1SDimitry Andric };
196fe6060f1SDimitry Andric 
197fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
198fe6060f1SDimitry Andric template <>
199fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS modulus<void>
200fe6060f1SDimitry Andric {
201fe6060f1SDimitry Andric     template <class _T1, class _T2>
202fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
203fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
204*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
205fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
206fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
207fe6060f1SDimitry Andric     typedef void is_transparent;
208fe6060f1SDimitry Andric };
209fe6060f1SDimitry Andric #endif
210fe6060f1SDimitry Andric 
211fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
212fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
213fe6060f1SDimitry Andric template <class _Tp = void>
214fe6060f1SDimitry Andric #else
215fe6060f1SDimitry Andric template <class _Tp>
216fe6060f1SDimitry Andric #endif
217fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS negate
218fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
219fe6060f1SDimitry Andric     : unary_function<_Tp, _Tp>
220fe6060f1SDimitry Andric #endif
221fe6060f1SDimitry Andric {
222fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
223fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
224fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
225fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
226fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
227fe6060f1SDimitry Andric #endif
228fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
229fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x) const
230fe6060f1SDimitry Andric         {return -__x;}
231fe6060f1SDimitry Andric };
232fe6060f1SDimitry Andric 
233fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
234fe6060f1SDimitry Andric template <>
235fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS negate<void>
236fe6060f1SDimitry Andric {
237fe6060f1SDimitry Andric     template <class _Tp>
238fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
239fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
240*349cc55cSDimitry Andric         noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
241fe6060f1SDimitry Andric         -> decltype(      - _VSTD::forward<_Tp>(__x))
242fe6060f1SDimitry Andric         { return          - _VSTD::forward<_Tp>(__x); }
243fe6060f1SDimitry Andric     typedef void is_transparent;
244fe6060f1SDimitry Andric };
245fe6060f1SDimitry Andric #endif
246fe6060f1SDimitry Andric 
247fe6060f1SDimitry Andric // Bitwise operations
248fe6060f1SDimitry Andric 
249fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
250fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
251fe6060f1SDimitry Andric template <class _Tp = void>
252fe6060f1SDimitry Andric #else
253fe6060f1SDimitry Andric template <class _Tp>
254fe6060f1SDimitry Andric #endif
255fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_and
256fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
257fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
258fe6060f1SDimitry Andric #endif
259fe6060f1SDimitry Andric {
260fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
261fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
262fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
263fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
264fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
265fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
266fe6060f1SDimitry Andric #endif
267fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
268fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
269fe6060f1SDimitry Andric         {return __x & __y;}
270fe6060f1SDimitry Andric };
271fe6060f1SDimitry Andric 
272fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
273fe6060f1SDimitry Andric template <>
274fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_and<void>
275fe6060f1SDimitry Andric {
276fe6060f1SDimitry Andric     template <class _T1, class _T2>
277fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
278fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
279*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
280fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
281fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
282fe6060f1SDimitry Andric     typedef void is_transparent;
283fe6060f1SDimitry Andric };
284fe6060f1SDimitry Andric #endif
285fe6060f1SDimitry Andric 
286fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
287fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
288fe6060f1SDimitry Andric template <class _Tp = void>
289fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_not
290fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
291fe6060f1SDimitry Andric     : unary_function<_Tp, _Tp>
292fe6060f1SDimitry Andric #endif
293fe6060f1SDimitry Andric {
294fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
295fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
296fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
297fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
298fe6060f1SDimitry Andric #endif
299fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
300fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x) const
301fe6060f1SDimitry Andric         {return ~__x;}
302fe6060f1SDimitry Andric };
303fe6060f1SDimitry Andric 
304fe6060f1SDimitry Andric template <>
305fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_not<void>
306fe6060f1SDimitry Andric {
307fe6060f1SDimitry Andric     template <class _Tp>
308fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
309fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
310*349cc55cSDimitry Andric         noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
311fe6060f1SDimitry Andric         -> decltype(      ~_VSTD::forward<_Tp>(__x))
312fe6060f1SDimitry Andric         { return          ~_VSTD::forward<_Tp>(__x); }
313fe6060f1SDimitry Andric     typedef void is_transparent;
314fe6060f1SDimitry Andric };
315fe6060f1SDimitry Andric #endif
316fe6060f1SDimitry Andric 
317fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
318fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
319fe6060f1SDimitry Andric template <class _Tp = void>
320fe6060f1SDimitry Andric #else
321fe6060f1SDimitry Andric template <class _Tp>
322fe6060f1SDimitry Andric #endif
323fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_or
324fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
325fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
326fe6060f1SDimitry Andric #endif
327fe6060f1SDimitry Andric {
328fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
329fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
330fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
331fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
332fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
333fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
334fe6060f1SDimitry Andric #endif
335fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
336fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
337fe6060f1SDimitry Andric         {return __x | __y;}
338fe6060f1SDimitry Andric };
339fe6060f1SDimitry Andric 
340fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
341fe6060f1SDimitry Andric template <>
342fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_or<void>
343fe6060f1SDimitry Andric {
344fe6060f1SDimitry Andric     template <class _T1, class _T2>
345fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
346fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
347*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
348fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
349fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
350fe6060f1SDimitry Andric     typedef void is_transparent;
351fe6060f1SDimitry Andric };
352fe6060f1SDimitry Andric #endif
353fe6060f1SDimitry Andric 
354fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
355fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
356fe6060f1SDimitry Andric template <class _Tp = void>
357fe6060f1SDimitry Andric #else
358fe6060f1SDimitry Andric template <class _Tp>
359fe6060f1SDimitry Andric #endif
360fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_xor
361fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
362fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, _Tp>
363fe6060f1SDimitry Andric #endif
364fe6060f1SDimitry Andric {
365fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
366fe6060f1SDimitry Andric     typedef _Tp __result_type;  // used by valarray
367fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
368fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
369fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
370fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
371fe6060f1SDimitry Andric #endif
372fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
373fe6060f1SDimitry Andric     _Tp operator()(const _Tp& __x, const _Tp& __y) const
374fe6060f1SDimitry Andric         {return __x ^ __y;}
375fe6060f1SDimitry Andric };
376fe6060f1SDimitry Andric 
377fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
378fe6060f1SDimitry Andric template <>
379fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
380fe6060f1SDimitry Andric {
381fe6060f1SDimitry Andric     template <class _T1, class _T2>
382fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
383fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
384*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
385fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
386fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
387fe6060f1SDimitry Andric     typedef void is_transparent;
388fe6060f1SDimitry Andric };
389fe6060f1SDimitry Andric #endif
390fe6060f1SDimitry Andric 
391fe6060f1SDimitry Andric // Comparison operations
392fe6060f1SDimitry Andric 
393fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
394fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
395fe6060f1SDimitry Andric template <class _Tp = void>
396fe6060f1SDimitry Andric #else
397fe6060f1SDimitry Andric template <class _Tp>
398fe6060f1SDimitry Andric #endif
399fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS equal_to
400fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
401fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
402fe6060f1SDimitry Andric #endif
403fe6060f1SDimitry Andric {
404fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
405fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
406fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
407fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
408fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
409fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
410fe6060f1SDimitry Andric #endif
411fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
412fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
413fe6060f1SDimitry Andric         {return __x == __y;}
414fe6060f1SDimitry Andric };
415fe6060f1SDimitry Andric 
416fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
417fe6060f1SDimitry Andric template <>
418fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS equal_to<void>
419fe6060f1SDimitry Andric {
420fe6060f1SDimitry Andric     template <class _T1, class _T2>
421fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
422fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
423*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
424fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
425fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
426fe6060f1SDimitry Andric     typedef void is_transparent;
427fe6060f1SDimitry Andric };
428fe6060f1SDimitry Andric #endif
429fe6060f1SDimitry Andric 
430fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
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 not_equal_to
437fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
438fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
439fe6060f1SDimitry Andric #endif
440fe6060f1SDimitry Andric {
441fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
442fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
443fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
444fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
445fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
446fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
447fe6060f1SDimitry Andric #endif
448fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
449fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
450fe6060f1SDimitry Andric         {return __x != __y;}
451fe6060f1SDimitry Andric };
452fe6060f1SDimitry Andric 
453fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
454fe6060f1SDimitry Andric template <>
455fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
456fe6060f1SDimitry Andric {
457fe6060f1SDimitry Andric     template <class _T1, class _T2>
458fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
459fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
460*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
461fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
462fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
463fe6060f1SDimitry Andric     typedef void is_transparent;
464fe6060f1SDimitry Andric };
465fe6060f1SDimitry Andric #endif
466fe6060f1SDimitry Andric 
467fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
468fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
469fe6060f1SDimitry Andric template <class _Tp = void>
470fe6060f1SDimitry Andric #else
471fe6060f1SDimitry Andric template <class _Tp>
472fe6060f1SDimitry Andric #endif
473fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less
474fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
475fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
476fe6060f1SDimitry Andric #endif
477fe6060f1SDimitry Andric {
478fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
479fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
480fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
481fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
482fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
483fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
484fe6060f1SDimitry Andric #endif
485fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
486fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
487fe6060f1SDimitry Andric         {return __x < __y;}
488fe6060f1SDimitry Andric };
489fe6060f1SDimitry Andric 
490fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
491fe6060f1SDimitry Andric template <>
492fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less<void>
493fe6060f1SDimitry Andric {
494fe6060f1SDimitry Andric     template <class _T1, class _T2>
495fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
496fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
497*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
498fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
499fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
500fe6060f1SDimitry Andric     typedef void is_transparent;
501fe6060f1SDimitry Andric };
502fe6060f1SDimitry Andric #endif
503fe6060f1SDimitry Andric 
504fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
505fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
506fe6060f1SDimitry Andric template <class _Tp = void>
507fe6060f1SDimitry Andric #else
508fe6060f1SDimitry Andric template <class _Tp>
509fe6060f1SDimitry Andric #endif
510fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less_equal
511fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
512fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
513fe6060f1SDimitry Andric #endif
514fe6060f1SDimitry Andric {
515fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
516fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
517fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
518fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
519fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
520fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
521fe6060f1SDimitry Andric #endif
522fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
523fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
524fe6060f1SDimitry Andric         {return __x <= __y;}
525fe6060f1SDimitry Andric };
526fe6060f1SDimitry Andric 
527fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
528fe6060f1SDimitry Andric template <>
529fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS less_equal<void>
530fe6060f1SDimitry Andric {
531fe6060f1SDimitry Andric     template <class _T1, class _T2>
532fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
533fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
534*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
535fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
536fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
537fe6060f1SDimitry Andric     typedef void is_transparent;
538fe6060f1SDimitry Andric };
539fe6060f1SDimitry Andric #endif
540fe6060f1SDimitry Andric 
541fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
542fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
543fe6060f1SDimitry Andric template <class _Tp = void>
544fe6060f1SDimitry Andric #else
545fe6060f1SDimitry Andric template <class _Tp>
546fe6060f1SDimitry Andric #endif
547fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater_equal
548fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
549fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
550fe6060f1SDimitry Andric #endif
551fe6060f1SDimitry Andric {
552fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
553fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
554fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
555fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
556fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
557fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
558fe6060f1SDimitry Andric #endif
559fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
560fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
561fe6060f1SDimitry Andric         {return __x >= __y;}
562fe6060f1SDimitry Andric };
563fe6060f1SDimitry Andric 
564fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
565fe6060f1SDimitry Andric template <>
566fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
567fe6060f1SDimitry Andric {
568fe6060f1SDimitry Andric     template <class _T1, class _T2>
569fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
570fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
571*349cc55cSDimitry 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_SUPPRESS_DEPRECATED_PUSH
579fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
580fe6060f1SDimitry Andric template <class _Tp = void>
581fe6060f1SDimitry Andric #else
582fe6060f1SDimitry Andric template <class _Tp>
583fe6060f1SDimitry Andric #endif
584fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater
585fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
586fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
587fe6060f1SDimitry Andric #endif
588fe6060f1SDimitry Andric {
589fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
590fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
591fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
592fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
593fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
594fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
595fe6060f1SDimitry Andric #endif
596fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
597fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
598fe6060f1SDimitry Andric         {return __x > __y;}
599fe6060f1SDimitry Andric };
600fe6060f1SDimitry Andric 
601fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
602fe6060f1SDimitry Andric template <>
603fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS greater<void>
604fe6060f1SDimitry Andric {
605fe6060f1SDimitry Andric     template <class _T1, class _T2>
606fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
607fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
608*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
609fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
610fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
611fe6060f1SDimitry Andric     typedef void is_transparent;
612fe6060f1SDimitry Andric };
613fe6060f1SDimitry Andric #endif
614fe6060f1SDimitry Andric 
615fe6060f1SDimitry Andric // Logical operations
616fe6060f1SDimitry Andric 
617fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
618fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
619fe6060f1SDimitry Andric template <class _Tp = void>
620fe6060f1SDimitry Andric #else
621fe6060f1SDimitry Andric template <class _Tp>
622fe6060f1SDimitry Andric #endif
623fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_and
624fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
625fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
626fe6060f1SDimitry Andric #endif
627fe6060f1SDimitry Andric {
628fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
629fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
630fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
631fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
632fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
633fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
634fe6060f1SDimitry Andric #endif
635fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
636fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
637fe6060f1SDimitry Andric         {return __x && __y;}
638fe6060f1SDimitry Andric };
639fe6060f1SDimitry Andric 
640fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
641fe6060f1SDimitry Andric template <>
642fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_and<void>
643fe6060f1SDimitry Andric {
644fe6060f1SDimitry Andric     template <class _T1, class _T2>
645fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
646fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
647*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
648fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
649fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
650fe6060f1SDimitry Andric     typedef void is_transparent;
651fe6060f1SDimitry Andric };
652fe6060f1SDimitry Andric #endif
653fe6060f1SDimitry Andric 
654fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
655fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
656fe6060f1SDimitry Andric template <class _Tp = void>
657fe6060f1SDimitry Andric #else
658fe6060f1SDimitry Andric template <class _Tp>
659fe6060f1SDimitry Andric #endif
660fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_not
661fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
662fe6060f1SDimitry Andric     : unary_function<_Tp, bool>
663fe6060f1SDimitry Andric #endif
664fe6060f1SDimitry Andric {
665fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
666fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
667fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
668fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
669fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
670fe6060f1SDimitry Andric #endif
671fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
672fe6060f1SDimitry Andric     bool operator()(const _Tp& __x) const
673fe6060f1SDimitry Andric         {return !__x;}
674fe6060f1SDimitry Andric };
675fe6060f1SDimitry Andric 
676fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
677fe6060f1SDimitry Andric template <>
678fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_not<void>
679fe6060f1SDimitry Andric {
680fe6060f1SDimitry Andric     template <class _Tp>
681fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
682fe6060f1SDimitry Andric     auto operator()(_Tp&& __x) const
683*349cc55cSDimitry Andric         noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
684fe6060f1SDimitry Andric         -> decltype(      !_VSTD::forward<_Tp>(__x))
685fe6060f1SDimitry Andric         { return          !_VSTD::forward<_Tp>(__x); }
686fe6060f1SDimitry Andric     typedef void is_transparent;
687fe6060f1SDimitry Andric };
688fe6060f1SDimitry Andric #endif
689fe6060f1SDimitry Andric 
690fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH
691fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
692fe6060f1SDimitry Andric template <class _Tp = void>
693fe6060f1SDimitry Andric #else
694fe6060f1SDimitry Andric template <class _Tp>
695fe6060f1SDimitry Andric #endif
696fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_or
697fe6060f1SDimitry Andric #if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
698fe6060f1SDimitry Andric     : binary_function<_Tp, _Tp, bool>
699fe6060f1SDimitry Andric #endif
700fe6060f1SDimitry Andric {
701fe6060f1SDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP
702fe6060f1SDimitry Andric     typedef bool __result_type;  // used by valarray
703fe6060f1SDimitry Andric #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
704fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
705fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
706fe6060f1SDimitry Andric     _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
707fe6060f1SDimitry Andric #endif
708fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
709fe6060f1SDimitry Andric     bool operator()(const _Tp& __x, const _Tp& __y) const
710fe6060f1SDimitry Andric         {return __x || __y;}
711fe6060f1SDimitry Andric };
712fe6060f1SDimitry Andric 
713fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11
714fe6060f1SDimitry Andric template <>
715fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS logical_or<void>
716fe6060f1SDimitry Andric {
717fe6060f1SDimitry Andric     template <class _T1, class _T2>
718fe6060f1SDimitry Andric     _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
719fe6060f1SDimitry Andric     auto operator()(_T1&& __t, _T2&& __u) const
720*349cc55cSDimitry Andric         noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
721fe6060f1SDimitry Andric         -> decltype(      _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
722fe6060f1SDimitry Andric         { return          _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
723fe6060f1SDimitry Andric     typedef void is_transparent;
724fe6060f1SDimitry Andric };
725fe6060f1SDimitry Andric #endif
726fe6060f1SDimitry Andric 
727fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
728fe6060f1SDimitry Andric 
729fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
730