brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · dc9da06 Raw
123 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H11#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H12 13#include <__concepts/equality_comparable.h>14#include <__concepts/totally_ordered.h>15#include <__config>16#include <__type_traits/desugars_to.h>17#include <__type_traits/is_generic_transparent_comparator.h>18#include <__utility/forward.h>19 20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#  pragma GCC system_header22#endif23 24_LIBCPP_BEGIN_NAMESPACE_STD25 26#if _LIBCPP_STD_VER >= 2027 28namespace ranges {29 30struct equal_to {31  template <class _Tp, class _Up>32    requires equality_comparable_with<_Tp, _Up>33  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const34      noexcept(noexcept(bool(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))) {35    return std::forward<_Tp>(__t) == std::forward<_Up>(__u);36  }37 38  using is_transparent = void;39};40 41struct not_equal_to {42  template <class _Tp, class _Up>43    requires equality_comparable_with<_Tp, _Up>44  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const45      noexcept(noexcept(bool(!(std::forward<_Tp>(__t) == std::forward<_Up>(__u))))) {46    return !(std::forward<_Tp>(__t) == std::forward<_Up>(__u));47  }48 49  using is_transparent = void;50};51 52struct less {53  template <class _Tp, class _Up>54    requires totally_ordered_with<_Tp, _Up>55  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const56      noexcept(noexcept(bool(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))) {57    return std::forward<_Tp>(__t) < std::forward<_Up>(__u);58  }59 60  using is_transparent = void;61};62 63struct less_equal {64  template <class _Tp, class _Up>65    requires totally_ordered_with<_Tp, _Up>66  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const67      noexcept(noexcept(bool(!(std::forward<_Up>(__u) < std::forward<_Tp>(__t))))) {68    return !(std::forward<_Up>(__u) < std::forward<_Tp>(__t));69  }70 71  using is_transparent = void;72};73 74struct greater {75  template <class _Tp, class _Up>76    requires totally_ordered_with<_Tp, _Up>77  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const78      noexcept(noexcept(bool(std::forward<_Up>(__u) < std::forward<_Tp>(__t)))) {79    return std::forward<_Up>(__u) < std::forward<_Tp>(__t);80  }81 82  using is_transparent = void;83};84 85struct greater_equal {86  template <class _Tp, class _Up>87    requires totally_ordered_with<_Tp, _Up>88  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const89      noexcept(noexcept(bool(!(std::forward<_Tp>(__t) < std::forward<_Up>(__u))))) {90    return !(std::forward<_Tp>(__t) < std::forward<_Up>(__u));91  }92 93  using is_transparent = void;94};95 96} // namespace ranges97 98// For ranges we do not require that the types on each side of the equality99// operator are of the same type100template <class _Tp, class _Up>101inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true;102 103template <class _Tp, class _Up>104inline const bool __desugars_to_v<__totally_ordered_less_tag, ranges::less, _Tp, _Up> = true;105 106template <class _Tp, class _Up>107inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true;108 109template <class _Tp, class _Up>110inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true;111 112template <>113inline const bool __is_generic_transparent_comparator_v<ranges::less> = true;114 115template <>116inline const bool __is_generic_transparent_comparator_v<ranges::greater> = true;117 118#endif // _LIBCPP_STD_VER >= 20119 120_LIBCPP_END_NAMESPACE_STD121 122#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H123