tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
three_way_comparable.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_COMPARE_THREE_WAY_COMPAREABLE_HPP
4#define TETL_COMPARE_THREE_WAY_COMPAREABLE_HPP
5
13
14namespace etl {
15namespace detail {
16template <typename T, typename Cat>
17concept compares_as = same_as<common_comparison_category_t<T, Cat>, Cat>;
18
19// clang-format off
20template<typename T, typename U>
21concept partially_ordered_with = requires(remove_reference_t<T> const& t, remove_reference_t<U> const& u) {
22 { t < u } -> boolean_testable;
23 { t > u } -> boolean_testable;
24 { t <= u } -> boolean_testable;
25 { t >= u } -> boolean_testable;
26 { u < t } -> boolean_testable;
27 { u > t } -> boolean_testable;
28 { u <= t } -> boolean_testable;
29 { u >= t } -> boolean_testable;
30};
31// clang-format on
32
33} // namespace detail
34
35// clang-format off
37template<typename T, typename Cat = partial_ordering>
40 detail::partially_ordered_with<T, T> &&
41 requires(remove_reference_t<T> const& a, remove_reference_t<T> const& b) {
42 { a <=> b } -> detail::compares_as<Cat>;
43 };
44// clang-format on
45} // namespace etl
46
47#endif // TETL_COMPARE_THREE_WAY_COMPAREABLE_HPP
Definition three_way_comparable.hpp:38
Definition weakly_equality_comparable_with.hpp:18
typename remove_reference< T >::type remove_reference_t
Definition remove_reference.hpp:28
Definition adjacent_find.hpp:8