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*06c3fb27SDimitry Andric #include <__type_traits/integral_constant.h> 17*06c3fb27SDimitry Andric #include <__type_traits/predicate_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 26*06c3fb27SDimitry 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> 33*06c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 34fe6060f1SDimitry Andric noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) { 35fe6060f1SDimitry Andric return _VSTD::forward<_Tp>(__t) == _VSTD::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> 44*06c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 45fe6060f1SDimitry Andric noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) { 46fe6060f1SDimitry Andric return !(_VSTD::forward<_Tp>(__t) == _VSTD::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> 55*06c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 56fe6060f1SDimitry Andric noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) { 57fe6060f1SDimitry Andric return _VSTD::forward<_Tp>(__t) < _VSTD::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> 66*06c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 67fe6060f1SDimitry Andric noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) { 68fe6060f1SDimitry Andric return !(_VSTD::forward<_Up>(__u) < _VSTD::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> 77*06c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 78fe6060f1SDimitry Andric noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) { 79fe6060f1SDimitry Andric return _VSTD::forward<_Up>(__u) < _VSTD::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> 88*06c3fb27SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp &&__t, _Up &&__u) const 89fe6060f1SDimitry Andric noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) { 90fe6060f1SDimitry Andric return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)); 91fe6060f1SDimitry Andric } 92fe6060f1SDimitry Andric 93fe6060f1SDimitry Andric using is_transparent = void; 94fe6060f1SDimitry Andric }; 95fe6060f1SDimitry Andric 96fe6060f1SDimitry Andric } // namespace ranges 9781ad6265SDimitry Andric 98*06c3fb27SDimitry Andric template <class _Lhs, class _Rhs> 99*06c3fb27SDimitry Andric struct __is_trivial_equality_predicate<ranges::equal_to, _Lhs, _Rhs> : true_type {}; 100*06c3fb27SDimitry Andric 101*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20 102fe6060f1SDimitry Andric 103fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD 104fe6060f1SDimitry Andric 105fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H 106