2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
11 #define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
13 #include <__concepts/equality_comparable.h>
14 #include <__concepts/totally_ordered.h>
16 #include <__type_traits/desugars_to.h>
17 #include <__utility/forward.h>
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 # pragma GCC system_header
23 _LIBCPP_BEGIN_NAMESPACE_STD
25 #if _LIBCPP_STD_VER >= 20
30 template <class _Tp
, class _Up
>
31 requires equality_comparable_with
<_Tp
, _Up
>
32 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr bool operator()(_Tp
&& __t
, _Up
&& __u
) const
33 noexcept(noexcept(bool(std::forward
<_Tp
>(__t
) == std::forward
<_Up
>(__u
)))) {
34 return std::forward
<_Tp
>(__t
) == std::forward
<_Up
>(__u
);
37 using is_transparent
= void;
41 template <class _Tp
, class _Up
>
42 requires equality_comparable_with
<_Tp
, _Up
>
43 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr bool operator()(_Tp
&& __t
, _Up
&& __u
) const
44 noexcept(noexcept(bool(!(std::forward
<_Tp
>(__t
) == std::forward
<_Up
>(__u
))))) {
45 return !(std::forward
<_Tp
>(__t
) == std::forward
<_Up
>(__u
));
48 using is_transparent
= void;
52 template <class _Tp
, class _Up
>
53 requires totally_ordered_with
<_Tp
, _Up
>
54 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr bool operator()(_Tp
&& __t
, _Up
&& __u
) const
55 noexcept(noexcept(bool(std::forward
<_Tp
>(__t
) < std::forward
<_Up
>(__u
)))) {
56 return std::forward
<_Tp
>(__t
) < std::forward
<_Up
>(__u
);
59 using is_transparent
= void;
63 template <class _Tp
, class _Up
>
64 requires totally_ordered_with
<_Tp
, _Up
>
65 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr bool operator()(_Tp
&& __t
, _Up
&& __u
) const
66 noexcept(noexcept(bool(!(std::forward
<_Up
>(__u
) < std::forward
<_Tp
>(__t
))))) {
67 return !(std::forward
<_Up
>(__u
) < std::forward
<_Tp
>(__t
));
70 using is_transparent
= void;
74 template <class _Tp
, class _Up
>
75 requires totally_ordered_with
<_Tp
, _Up
>
76 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr bool operator()(_Tp
&& __t
, _Up
&& __u
) const
77 noexcept(noexcept(bool(std::forward
<_Up
>(__u
) < std::forward
<_Tp
>(__t
)))) {
78 return std::forward
<_Up
>(__u
) < std::forward
<_Tp
>(__t
);
81 using is_transparent
= void;
84 struct greater_equal
{
85 template <class _Tp
, class _Up
>
86 requires totally_ordered_with
<_Tp
, _Up
>
87 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr bool operator()(_Tp
&& __t
, _Up
&& __u
) const
88 noexcept(noexcept(bool(!(std::forward
<_Tp
>(__t
) < std::forward
<_Up
>(__u
))))) {
89 return !(std::forward
<_Tp
>(__t
) < std::forward
<_Up
>(__u
));
92 using is_transparent
= void;
97 // For ranges we do not require that the types on each side of the equality
98 // operator are of the same type
99 template <class _Tp
, class _Up
>
100 inline const bool __desugars_to_v
<__equal_tag
, ranges::equal_to
, _Tp
, _Up
> = true;
102 template <class _Tp
, class _Up
>
103 inline const bool __desugars_to_v
<__totally_ordered_less_tag
, ranges::less
, _Tp
, _Up
> = true;
105 template <class _Tp
, class _Up
>
106 inline const bool __desugars_to_v
<__less_tag
, ranges::less
, _Tp
, _Up
> = true;
108 template <class _Tp
, class _Up
>
109 inline const bool __desugars_to_v
<__greater_tag
, ranges::greater
, _Tp
, _Up
> = true;
111 #endif // _LIBCPP_STD_VER >= 20
113 _LIBCPP_END_NAMESPACE_STD
115 #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H