File indexing completed on 2026-05-03 08:13:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___COMPARE_SYNTH_THREE_WAY_H
0010 #define _LIBCPP___CXX03___COMPARE_SYNTH_THREE_WAY_H
0011
0012 #include <__cxx03/__compare/ordering.h>
0013 #include <__cxx03/__compare/three_way_comparable.h>
0014 #include <__cxx03/__concepts/boolean_testable.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__utility/declval.h>
0017
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 # pragma GCC system_header
0020 #endif
0021
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023
0024 #if _LIBCPP_STD_VER >= 20
0025
0026
0027
0028 _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
0029 requires requires {
0030 { __t < __u } -> __boolean_testable;
0031 { __u < __t } -> __boolean_testable;
0032 }
0033 {
0034 if constexpr (three_way_comparable_with<_Tp, _Up>) {
0035 return __t <=> __u;
0036 } else {
0037 if (__t < __u)
0038 return weak_ordering::less;
0039 if (__u < __t)
0040 return weak_ordering::greater;
0041 return weak_ordering::equivalent;
0042 }
0043 };
0044
0045 template <class _Tp, class _Up = _Tp>
0046 using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
0047
0048 #endif
0049
0050 _LIBCPP_END_NAMESPACE_STD
0051
0052 #endif