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