File indexing completed on 2026-05-03 08:13:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___COMPARE_THREE_WAY_COMPARABLE_H
0010 #define _LIBCPP___CXX03___COMPARE_THREE_WAY_COMPARABLE_H
0011
0012 #include <__cxx03/__compare/common_comparison_category.h>
0013 #include <__cxx03/__compare/ordering.h>
0014 #include <__cxx03/__concepts/common_reference_with.h>
0015 #include <__cxx03/__concepts/equality_comparable.h>
0016 #include <__cxx03/__concepts/same_as.h>
0017 #include <__cxx03/__concepts/totally_ordered.h>
0018 #include <__cxx03/__config>
0019 #include <__cxx03/__type_traits/common_reference.h>
0020 #include <__cxx03/__type_traits/make_const_lvalue_ref.h>
0021
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 # pragma GCC system_header
0024 #endif
0025
0026 _LIBCPP_BEGIN_NAMESPACE_STD
0027
0028 #if _LIBCPP_STD_VER >= 20
0029
0030 template <class _Tp, class _Cat>
0031 concept __compares_as = same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
0032
0033 template <class _Tp, class _Cat = partial_ordering>
0034 concept three_way_comparable =
0035 __weakly_equality_comparable_with<_Tp, _Tp> && __partially_ordered_with<_Tp, _Tp> &&
0036 requires(__make_const_lvalue_ref<_Tp> __a, __make_const_lvalue_ref<_Tp> __b) {
0037 { __a <=> __b } -> __compares_as<_Cat>;
0038 };
0039
0040 template <class _Tp, class _Up, class _Cat = partial_ordering>
0041 concept three_way_comparable_with =
0042 three_way_comparable<_Tp, _Cat> && three_way_comparable<_Up, _Cat> &&
0043 common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
0044 three_way_comparable<common_reference_t<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>, _Cat> &&
0045 __weakly_equality_comparable_with<_Tp, _Up> && __partially_ordered_with<_Tp, _Up> &&
0046 requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
0047 { __t <=> __u } -> __compares_as<_Cat>;
0048 { __u <=> __t } -> __compares_as<_Cat>;
0049 };
0050
0051 #endif
0052
0053 _LIBCPP_END_NAMESPACE_STD
0054
0055 #endif