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_STRONG_ORDER_FALLBACK
0010 #define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
0011 
0012 #include <__compare/ordering.h>
0013 #include <__compare/strong_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_strong_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::strong_order(std::forward<_Tp>(__t), std::forward<_Up>(__u))))
0036       -> decltype(std::strong_order(std::forward<_Tp>(__t), std::forward<_Up>(__u))) {
0037     return std::strong_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     }
0045   _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(
0046       noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)  ? strong_ordering::equal
0047                : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? strong_ordering::less
0048                                                                  : strong_ordering::greater)) {
0049     return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal
0050          : std::forward<_Tp>(__t) < std::forward<_Up>(__u)
0051              ? strong_ordering::less
0052              : strong_ordering::greater;
0053   }
0054 
0055   template <class _Tp, class _Up>
0056   _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
0057       noexcept(noexcept(__go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<1>())))
0058           -> decltype(__go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<1>())) {
0059     return __go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<1>());
0060   }
0061 };
0062 } // namespace __compare_strong_order_fallback
0063 
0064 inline namespace __cpo {
0065 inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{};
0066 } // namespace __cpo
0067 
0068 #endif // _LIBCPP_STD_VER >= 20
0069 
0070 _LIBCPP_END_NAMESPACE_STD
0071 
0072 #endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK