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