5#ifndef DUNE_COMMON_STD_COMPARE_HH
6#define DUNE_COMMON_STD_COMPARE_HH
22template <
class T,
class Cat>
24 std::same_as<std::common_comparison_category_t<T, Cat>, Cat>;
26template <
class T,
class U>
27concept weaklyEqualityComparableWith =
28 requires(
const std::remove_reference_t<T>& t,
29 const std::remove_reference_t<U>& u)
31 { t == u } -> std::convertible_to<bool>;
32 { t != u } -> std::convertible_to<bool>;
33 { u == t } -> std::convertible_to<bool>;
34 { u != t } -> std::convertible_to<bool>;
37template <
class T,
class U>
38concept partiallyOrderedWith =
39 requires(
const std::remove_reference_t<T>& t,
40 const std::remove_reference_t<U>& u)
42 { t < u } -> std::convertible_to<bool>;
43 { t > u } -> std::convertible_to<bool>;
44 { t <= u } -> std::convertible_to<bool>;
45 { t >= u } -> std::convertible_to<bool>;
46 { u < t } -> std::convertible_to<bool>;
47 { u > t } -> std::convertible_to<bool>;
48 { u <= t } -> std::convertible_to<bool>;
49 { u >= t } -> std::convertible_to<bool>;
52template <
class T,
class U,
class C = std::common_reference_t<const T&, const U&>>
53concept comparisonCommonTypeWithImpl =
54 std::same_as<std::common_reference_t<const T&, const U&>,
55 std::common_reference_t<const U&, const T&>> &&
58 requires std::convertible_to<const T&, const C&> ||
59 std::convertible_to<T, const C&>;
60 requires std::convertible_to<const U&, const C&> ||
61 std::convertible_to<U, const C&>;
64template <
class T,
class U>
65concept comparisonCommonTypeWith =
66 comparisonCommonTypeWithImpl<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;
77template <
class T,
class Cat = std::partial_ordering>
79 Impl::weaklyEqualityComparableWith<T, T> &&
80 Impl::partiallyOrderedWith<T, T> &&
81 requires(
const std::remove_reference_t<T>& a,
82 const std::remove_reference_t<T>& b)
84 { a <=> b } -> Impl::comparesAs<Cat>;
97template <
class T,
class U,
class Cat = std::partial_ordering>
101 Impl::comparisonCommonTypeWith<T, U> &&
103 std::common_reference_t<
104 const std::remove_reference_t<T>&,
105 const std::remove_reference_t<U>&>, Cat> &&
106 Impl::weaklyEqualityComparableWith<T, U> &&
107 Impl::partiallyOrderedWith<T, U> &&
108 requires(
const std::remove_reference_t<T>& t,
109 const std::remove_reference_t<U>& u)
111 { t <=> u } -> Impl::comparesAs<Cat>;
112 { u <=> t } -> Impl::comparesAs<Cat>;
118 template <
class T,
class U>
119 constexpr auto operator() (T&& t, U&& u)
const
121 return std::forward<T>(t) <=> std::forward<U>(u);
The concept std::three_way_comparable_with specifies that the three way comparison operator <=> on (p...
Definition: compare.hh:98
The concept std::three_way_comparable specifies that the three way comparison operator <=> on T yield...
Definition: compare.hh:78
Namespace for features backported from new C++ standards.
Definition: algorithm.hh:19
A functor implementing the three-way comparison on the arguments.
Definition: compare.hh:117