Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:16

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
0010 #define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
0011 
0012 #include <__compare/ordering.h>
0013 #include <__compare/partial_order.h>
0014 #include <__concepts/boolean_testable.h>
0015 #include <__config>
0016 #include <__type_traits/decay.h>
0017 #include <__type_traits/is_same.h>
0018 #include <__utility/forward.h>
0019 #include <__utility/priority_tag.h>
0020 
0021 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
0022 #  pragma GCC system_header
0023 #endif
0024 
0025 _LIBCPP_BEGIN_NAMESPACE_STD
0026 
0027 #if _LIBCPP_STD_VER >= 20
0028 
0029 // [cmp.alg]
0030 namespace __compare_partial_order_fallback {
0031 struct __fn {
0032   template <class _Tp, class _Up>
0033     requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
0034   _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(
0035       noexcept(std::partial_order(std::forward<_Tp>(__t), std::forward<_Up>(__u))))
0036       -> decltype(std::partial_order(std::forward<_Tp>(__t), std::forward<_Up>(__u))) {
0037     return std::partial_order(std::forward<_Tp>(__t), std::forward<_Up>(__u));
0038   }
0039 
0040   template <class _Tp, class _Up>
0041     requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) {
0042       { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable;
0043       { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable;
0044       { std::forward<_Up>(__u) < std::forward<_Tp>(__t) } -> __boolean_testable;
0045     }
0046   _LIBCPP_HIDE_FROM_ABI static constexpr partial_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(
0047       noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)  ? partial_ordering::equivalent
0048                : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less
0049                : std::forward<_Up>(__u) < std::forward<_Tp>(__t) ? partial_ordering::greater
0050                                                                  : partial_ordering::unordered)) {
0051     return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent
0052          : std::forward<_Tp>(__t) < std::forward<_Up>(__u)  ? partial_ordering::less
0053          : std::forward<_Up>(__u) < std::forward<_Tp>(__t)
0054              ? partial_ordering::greater
0055              : partial_ordering::unordered;
0056   }
0057 
0058   template <class _Tp, class _Up>
0059   _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
0060       noexcept(noexcept(__go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<1>())))
0061           -> decltype(__go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<1>())) {
0062     return __go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<1>());
0063   }
0064 };
0065 } // namespace __compare_partial_order_fallback
0066 
0067 inline namespace __cpo {
0068 inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{};
0069 } // namespace __cpo
0070 
0071 #endif // _LIBCPP_STD_VER >= 20
0072 
0073 _LIBCPP_END_NAMESPACE_STD
0074 
0075 #endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK