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