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 13bdd1243dSDimitry Andric #include <__concepts/equality_comparable.h> 14bdd1243dSDimitry Andric #include <__concepts/totally_ordered.h> 15fe6060f1SDimitry Andric #include <__config> 1606c3fb27SDimitry Andric #include <__type_traits/integral_constant.h> 17*5f757f3fSDimitry Andric #include <__type_traits/operation_traits.h> 1881ad6265SDimitry Andric #include <__utility/forward.h> 19fe6060f1SDimitry Andric 20fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 21fe6060f1SDimitry Andric # pragma GCC system_header 22fe6060f1SDimitry Andric #endif 23fe6060f1SDimitry Andric 24fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 25fe6060f1SDimitry Andric 2606c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20 27d56accc7SDimitry Andric 28fe6060f1SDimitry Andric namespace ranges { 29fe6060f1SDimitry Andric 30fe6060f1SDimitry Andric struct equal_to { 31fe6060f1SDimitry Andric template <class _Tp, class _Up> 32fe6060f1SDimitry Andric requires equality_comparable_with<_Tp, _Up> 3306c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 34*5f757f3fSDimitry Andric noexcept(noexcept(bool(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))) { 35*5f757f3fSDimitry Andric return std::forward<_Tp>(__t) == std::forward<_Up>(__u); 36fe6060f1SDimitry Andric } 37fe6060f1SDimitry Andric 38fe6060f1SDimitry Andric using is_transparent = void; 39fe6060f1SDimitry Andric }; 40fe6060f1SDimitry Andric 41fe6060f1SDimitry Andric struct not_equal_to { 42fe6060f1SDimitry Andric template <class _Tp, class _Up> 43fe6060f1SDimitry Andric requires equality_comparable_with<_Tp, _Up> 4406c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 45*5f757f3fSDimitry Andric noexcept(noexcept(bool(!(std::forward<_Tp>(__t) == std::forward<_Up>(__u))))) { 46*5f757f3fSDimitry Andric return !(std::forward<_Tp>(__t) == std::forward<_Up>(__u)); 47fe6060f1SDimitry Andric } 48fe6060f1SDimitry Andric 49fe6060f1SDimitry Andric using is_transparent = void; 50fe6060f1SDimitry Andric }; 51fe6060f1SDimitry Andric 52fe6060f1SDimitry Andric struct less { 53fe6060f1SDimitry Andric template <class _Tp, class _Up> 54fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 5506c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 56*5f757f3fSDimitry Andric noexcept(noexcept(bool(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))) { 57*5f757f3fSDimitry Andric return std::forward<_Tp>(__t) < std::forward<_Up>(__u); 58fe6060f1SDimitry Andric } 59fe6060f1SDimitry Andric 60fe6060f1SDimitry Andric using is_transparent = void; 61fe6060f1SDimitry Andric }; 62fe6060f1SDimitry Andric 63fe6060f1SDimitry Andric struct less_equal { 64fe6060f1SDimitry Andric template <class _Tp, class _Up> 65fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 6606c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 67*5f757f3fSDimitry Andric noexcept(noexcept(bool(!(std::forward<_Up>(__u) < std::forward<_Tp>(__t))))) { 68*5f757f3fSDimitry Andric return !(std::forward<_Up>(__u) < std::forward<_Tp>(__t)); 69fe6060f1SDimitry Andric } 70fe6060f1SDimitry Andric 71fe6060f1SDimitry Andric using is_transparent = void; 72fe6060f1SDimitry Andric }; 73fe6060f1SDimitry Andric 74fe6060f1SDimitry Andric struct greater { 75fe6060f1SDimitry Andric template <class _Tp, class _Up> 76fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 7706c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 78*5f757f3fSDimitry Andric noexcept(noexcept(bool(std::forward<_Up>(__u) < std::forward<_Tp>(__t)))) { 79*5f757f3fSDimitry Andric return std::forward<_Up>(__u) < std::forward<_Tp>(__t); 80fe6060f1SDimitry Andric } 81fe6060f1SDimitry Andric 82fe6060f1SDimitry Andric using is_transparent = void; 83fe6060f1SDimitry Andric }; 84fe6060f1SDimitry Andric 85fe6060f1SDimitry Andric struct greater_equal { 86fe6060f1SDimitry Andric template <class _Tp, class _Up> 87fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 8806c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 89*5f757f3fSDimitry Andric noexcept(noexcept(bool(!(std::forward<_Tp>(__t) < std::forward<_Up>(__u))))) { 90*5f757f3fSDimitry Andric return !(std::forward<_Tp>(__t) < std::forward<_Up>(__u)); 91fe6060f1SDimitry Andric } 92fe6060f1SDimitry Andric 93fe6060f1SDimitry Andric using is_transparent = void; 94fe6060f1SDimitry Andric }; 95fe6060f1SDimitry Andric 96fe6060f1SDimitry Andric } // namespace ranges 9781ad6265SDimitry Andric 98*5f757f3fSDimitry Andric // For ranges we do not require that the types on each side of the equality 99*5f757f3fSDimitry Andric // operator are of the same type 100*5f757f3fSDimitry Andric template <class _Tp, class _Up> 101*5f757f3fSDimitry Andric struct __desugars_to<__equal_tag, ranges::equal_to, _Tp, _Up> : true_type {}; 10206c3fb27SDimitry Andric 10306c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20 104fe6060f1SDimitry Andric 105fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD 106fe6060f1SDimitry Andric 107fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H 108