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