xref: /freebsd-src/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1fe6060f1SDimitry Andric // -*- C++ -*-
2fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
3fe6060f1SDimitry Andric //
4fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
6fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7fe6060f1SDimitry Andric //
8fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
9fe6060f1SDimitry Andric 
10fe6060f1SDimitry Andric #ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
11fe6060f1SDimitry Andric #define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
12fe6060f1SDimitry Andric 
13fe6060f1SDimitry Andric #include <__config>
14*81ad6265SDimitry Andric #include <__utility/forward.h>
15fe6060f1SDimitry Andric #include <concepts>
16fe6060f1SDimitry Andric 
17fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18fe6060f1SDimitry Andric #  pragma GCC system_header
19fe6060f1SDimitry Andric #endif
20fe6060f1SDimitry Andric 
21fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
22fe6060f1SDimitry Andric 
23*81ad6265SDimitry Andric #if _LIBCPP_STD_VER > 17
24d56accc7SDimitry Andric 
25fe6060f1SDimitry Andric namespace ranges {
26fe6060f1SDimitry Andric 
27fe6060f1SDimitry Andric struct equal_to {
28fe6060f1SDimitry Andric   template <class _Tp, class _Up>
29fe6060f1SDimitry Andric   requires equality_comparable_with<_Tp, _Up>
30fe6060f1SDimitry Andric   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
31fe6060f1SDimitry Andric       noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) {
32fe6060f1SDimitry Andric     return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u);
33fe6060f1SDimitry Andric   }
34fe6060f1SDimitry Andric 
35fe6060f1SDimitry Andric   using is_transparent = void;
36fe6060f1SDimitry Andric };
37fe6060f1SDimitry Andric 
38fe6060f1SDimitry Andric struct not_equal_to {
39fe6060f1SDimitry Andric   template <class _Tp, class _Up>
40fe6060f1SDimitry Andric   requires equality_comparable_with<_Tp, _Up>
41fe6060f1SDimitry Andric   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
42fe6060f1SDimitry Andric       noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) {
43fe6060f1SDimitry Andric     return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u));
44fe6060f1SDimitry Andric   }
45fe6060f1SDimitry Andric 
46fe6060f1SDimitry Andric   using is_transparent = void;
47fe6060f1SDimitry Andric };
48fe6060f1SDimitry Andric 
49fe6060f1SDimitry Andric struct less {
50fe6060f1SDimitry Andric   template <class _Tp, class _Up>
51fe6060f1SDimitry Andric   requires totally_ordered_with<_Tp, _Up>
52fe6060f1SDimitry Andric   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
53fe6060f1SDimitry Andric       noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) {
54fe6060f1SDimitry Andric     return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u);
55fe6060f1SDimitry Andric   }
56fe6060f1SDimitry Andric 
57fe6060f1SDimitry Andric   using is_transparent = void;
58fe6060f1SDimitry Andric };
59fe6060f1SDimitry Andric 
60fe6060f1SDimitry Andric struct less_equal {
61fe6060f1SDimitry Andric   template <class _Tp, class _Up>
62fe6060f1SDimitry Andric   requires totally_ordered_with<_Tp, _Up>
63fe6060f1SDimitry Andric   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
64fe6060f1SDimitry Andric       noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) {
65fe6060f1SDimitry Andric     return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t));
66fe6060f1SDimitry Andric   }
67fe6060f1SDimitry Andric 
68fe6060f1SDimitry Andric   using is_transparent = void;
69fe6060f1SDimitry Andric };
70fe6060f1SDimitry Andric 
71fe6060f1SDimitry Andric struct greater {
72fe6060f1SDimitry Andric   template <class _Tp, class _Up>
73fe6060f1SDimitry Andric   requires totally_ordered_with<_Tp, _Up>
74fe6060f1SDimitry Andric   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
75fe6060f1SDimitry Andric       noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) {
76fe6060f1SDimitry Andric     return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t);
77fe6060f1SDimitry Andric   }
78fe6060f1SDimitry Andric 
79fe6060f1SDimitry Andric   using is_transparent = void;
80fe6060f1SDimitry Andric };
81fe6060f1SDimitry Andric 
82fe6060f1SDimitry Andric struct greater_equal {
83fe6060f1SDimitry Andric   template <class _Tp, class _Up>
84fe6060f1SDimitry Andric   requires totally_ordered_with<_Tp, _Up>
85fe6060f1SDimitry Andric   [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
86fe6060f1SDimitry Andric       noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) {
87fe6060f1SDimitry Andric     return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u));
88fe6060f1SDimitry Andric   }
89fe6060f1SDimitry Andric 
90fe6060f1SDimitry Andric   using is_transparent = void;
91fe6060f1SDimitry Andric };
92fe6060f1SDimitry Andric 
93fe6060f1SDimitry Andric } // namespace ranges
94*81ad6265SDimitry Andric 
95*81ad6265SDimitry Andric #endif // _LIBCPP_STD_VER > 17
96fe6060f1SDimitry Andric 
97fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
98fe6060f1SDimitry Andric 
99fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
100