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 <concepts>
15 #include <utility>
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 !defined(_LIBCPP_HAS_NO_RANGES)
24 namespace ranges {
25 
26 struct equal_to {
27   template <class _Tp, class _Up>
28   requires equality_comparable_with<_Tp, _Up>
operatorequal_to29   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
30       noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) {
31     return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u);
32   }
33 
34   using is_transparent = void;
35 };
36 
37 struct not_equal_to {
38   template <class _Tp, class _Up>
39   requires equality_comparable_with<_Tp, _Up>
operatornot_equal_to40   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
41       noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) {
42     return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u));
43   }
44 
45   using is_transparent = void;
46 };
47 
48 struct less {
49   template <class _Tp, class _Up>
50   requires totally_ordered_with<_Tp, _Up>
operatorless51   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
52       noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) {
53     return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u);
54   }
55 
56   using is_transparent = void;
57 };
58 
59 struct less_equal {
60   template <class _Tp, class _Up>
61   requires totally_ordered_with<_Tp, _Up>
operatorless_equal62   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
63       noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) {
64     return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t));
65   }
66 
67   using is_transparent = void;
68 };
69 
70 struct greater {
71   template <class _Tp, class _Up>
72   requires totally_ordered_with<_Tp, _Up>
operatorgreater73   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
74       noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) {
75     return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t);
76   }
77 
78   using is_transparent = void;
79 };
80 
81 struct greater_equal {
82   template <class _Tp, class _Up>
83   requires totally_ordered_with<_Tp, _Up>
operatorgreater_equal84   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
85       noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) {
86     return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u));
87   }
88 
89   using is_transparent = void;
90 };
91 
92 } // namespace ranges
93 #endif // !defined(_LIBCPP_HAS_NO_RANGES)
94 
95 _LIBCPP_END_NAMESPACE_STD
96 
97 #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
98