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> 16*0fca6ea1SDimitry Andric #include <__type_traits/desugars_to.h> 1781ad6265SDimitry Andric #include <__utility/forward.h> 18fe6060f1SDimitry Andric 19fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 20fe6060f1SDimitry Andric # pragma GCC system_header 21fe6060f1SDimitry Andric #endif 22fe6060f1SDimitry Andric 23fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 24fe6060f1SDimitry Andric 2506c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20 26d56accc7SDimitry Andric 27fe6060f1SDimitry Andric namespace ranges { 28fe6060f1SDimitry Andric 29fe6060f1SDimitry Andric struct equal_to { 30fe6060f1SDimitry Andric template <class _Tp, class _Up> 31fe6060f1SDimitry Andric requires equality_comparable_with<_Tp, _Up> 3206c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const 335f757f3fSDimitry Andric noexcept(noexcept(bool(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))) { 345f757f3fSDimitry Andric return std::forward<_Tp>(__t) == std::forward<_Up>(__u); 35fe6060f1SDimitry Andric } 36fe6060f1SDimitry Andric 37fe6060f1SDimitry Andric using is_transparent = void; 38fe6060f1SDimitry Andric }; 39fe6060f1SDimitry Andric 40fe6060f1SDimitry Andric struct not_equal_to { 41fe6060f1SDimitry Andric template <class _Tp, class _Up> 42fe6060f1SDimitry Andric requires equality_comparable_with<_Tp, _Up> 4306c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const 445f757f3fSDimitry Andric noexcept(noexcept(bool(!(std::forward<_Tp>(__t) == std::forward<_Up>(__u))))) { 455f757f3fSDimitry Andric return !(std::forward<_Tp>(__t) == std::forward<_Up>(__u)); 46fe6060f1SDimitry Andric } 47fe6060f1SDimitry Andric 48fe6060f1SDimitry Andric using is_transparent = void; 49fe6060f1SDimitry Andric }; 50fe6060f1SDimitry Andric 51fe6060f1SDimitry Andric struct less { 52fe6060f1SDimitry Andric template <class _Tp, class _Up> 53fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 5406c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const 555f757f3fSDimitry Andric noexcept(noexcept(bool(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))) { 565f757f3fSDimitry Andric return std::forward<_Tp>(__t) < std::forward<_Up>(__u); 57fe6060f1SDimitry Andric } 58fe6060f1SDimitry Andric 59fe6060f1SDimitry Andric using is_transparent = void; 60fe6060f1SDimitry Andric }; 61fe6060f1SDimitry Andric 62fe6060f1SDimitry Andric struct less_equal { 63fe6060f1SDimitry Andric template <class _Tp, class _Up> 64fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 6506c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const 665f757f3fSDimitry Andric noexcept(noexcept(bool(!(std::forward<_Up>(__u) < std::forward<_Tp>(__t))))) { 675f757f3fSDimitry Andric return !(std::forward<_Up>(__u) < std::forward<_Tp>(__t)); 68fe6060f1SDimitry Andric } 69fe6060f1SDimitry Andric 70fe6060f1SDimitry Andric using is_transparent = void; 71fe6060f1SDimitry Andric }; 72fe6060f1SDimitry Andric 73fe6060f1SDimitry Andric struct greater { 74fe6060f1SDimitry Andric template <class _Tp, class _Up> 75fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 7606c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const 775f757f3fSDimitry Andric noexcept(noexcept(bool(std::forward<_Up>(__u) < std::forward<_Tp>(__t)))) { 785f757f3fSDimitry Andric return std::forward<_Up>(__u) < std::forward<_Tp>(__t); 79fe6060f1SDimitry Andric } 80fe6060f1SDimitry Andric 81fe6060f1SDimitry Andric using is_transparent = void; 82fe6060f1SDimitry Andric }; 83fe6060f1SDimitry Andric 84fe6060f1SDimitry Andric struct greater_equal { 85fe6060f1SDimitry Andric template <class _Tp, class _Up> 86fe6060f1SDimitry Andric requires totally_ordered_with<_Tp, _Up> 8706c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const 885f757f3fSDimitry Andric noexcept(noexcept(bool(!(std::forward<_Tp>(__t) < std::forward<_Up>(__u))))) { 895f757f3fSDimitry Andric return !(std::forward<_Tp>(__t) < std::forward<_Up>(__u)); 90fe6060f1SDimitry Andric } 91fe6060f1SDimitry Andric 92fe6060f1SDimitry Andric using is_transparent = void; 93fe6060f1SDimitry Andric }; 94fe6060f1SDimitry Andric 95fe6060f1SDimitry Andric } // namespace ranges 9681ad6265SDimitry Andric 975f757f3fSDimitry Andric // For ranges we do not require that the types on each side of the equality 985f757f3fSDimitry Andric // operator are of the same type 995f757f3fSDimitry Andric template <class _Tp, class _Up> 100*0fca6ea1SDimitry Andric inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true; 101*0fca6ea1SDimitry Andric 102*0fca6ea1SDimitry Andric template <class _Tp, class _Up> 103*0fca6ea1SDimitry Andric inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true; 10406c3fb27SDimitry Andric 10506c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20 106fe6060f1SDimitry Andric 107fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD 108fe6060f1SDimitry Andric 109fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H 110