17#ifndef CPP_COMPARE_HPP
18#define CPP_COMPARE_HPP
20#if __cplusplus > 201703L && __has_include(<compare>) && \
21 defined(__cpp_concepts) && defined(__cpp_impl_three_way_comparison)
35 template<
typename T,
typename Cat>
36 concept compares_as = same_as<ranges::common_comparison_category_t<T, Cat>, Cat>;
41 template<
typename T,
typename Cat = std::partial_ordering>
42 concept three_way_comparable =
43 detail::weakly_equality_comparable_with_<T, T> &&
44 detail::partially_ordered_with_<T ,T> &&
45 requires(detail::as_cref_t<T>& a, detail::as_cref_t<T>& b) {
46 { a <=> b } -> detail::compares_as<Cat>;
49 template<
typename T,
typename U,
typename Cat = std::partial_ordering>
50 concept three_way_comparable_with =
51 three_way_comparable<T, Cat> &&
52 three_way_comparable<U, Cat> &&
53 common_reference_with<detail::as_cref_t<T>&, detail::as_cref_t<U>&> &&
54 three_way_comparable<common_reference_t<detail::as_cref_t<T>&, detail::as_cref_t<U>&>> &&
55 detail::partially_ordered_with_<T, U> &&
56 requires(detail::as_cref_t<T>& t, detail::as_cref_t<U>& u) {
57 { t <=> u } -> detail::compares_as<Cat>;
58 { u <=> t } -> detail::compares_as<Cat>;