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_RANGES_OPERATIONS_H 11 #define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H 12 13 #include <__config> 14 #include <__utility/forward.h> 15 #include <concepts> 16 17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 18 # pragma GCC system_header 19 #endif 20 21 _LIBCPP_BEGIN_NAMESPACE_STD 22 23 #if _LIBCPP_STD_VER > 17 24 25 namespace ranges { 26 27 struct equal_to { 28 template <class _Tp, class _Up> 29 requires equality_comparable_with<_Tp, _Up> 30 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 31 noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) { 32 return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u); 33 } 34 35 using is_transparent = void; 36 }; 37 38 struct not_equal_to { 39 template <class _Tp, class _Up> 40 requires equality_comparable_with<_Tp, _Up> 41 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 42 noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) { 43 return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)); 44 } 45 46 using is_transparent = void; 47 }; 48 49 struct less { 50 template <class _Tp, class _Up> 51 requires totally_ordered_with<_Tp, _Up> 52 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 53 noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) { 54 return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u); 55 } 56 57 using is_transparent = void; 58 }; 59 60 struct less_equal { 61 template <class _Tp, class _Up> 62 requires totally_ordered_with<_Tp, _Up> 63 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 64 noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) { 65 return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)); 66 } 67 68 using is_transparent = void; 69 }; 70 71 struct greater { 72 template <class _Tp, class _Up> 73 requires totally_ordered_with<_Tp, _Up> 74 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 75 noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) { 76 return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t); 77 } 78 79 using is_transparent = void; 80 }; 81 82 struct greater_equal { 83 template <class _Tp, class _Up> 84 requires totally_ordered_with<_Tp, _Up> 85 [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const 86 noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) { 87 return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)); 88 } 89 90 using is_transparent = void; 91 }; 92 93 } // namespace ranges 94 95 #endif // _LIBCPP_STD_VER > 17 96 97 _LIBCPP_END_NAMESPACE_STD 98 99 #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H 100