16 #ifndef OPENKALMAN_COORDINATES_COMPARE_PATTERN_COLLECTIONS_HPP 17 #define OPENKALMAN_COORDINATES_COMPARE_PATTERN_COLLECTIONS_HPP 29 template<auto comp, std::
size_t i = 0_uz,
typename A,
typename B>
31 compare_pattern_collections_a_tail(
const A& a,
const B& b)
33 constexpr
auto ix = std::integral_constant<std::size_t, i>{};
34 if constexpr (i < collections::size_of_v<A>)
35 return compare<comp>(collections::get<ix>(a), Dimensions<1>{}) and
36 compare_pattern_collections_a_tail<comp, i + 1>(a, b);
38 return std::true_type {};
42 template<auto comp, std::
size_t i = 0_uz,
typename A,
typename B>
44 compare_pattern_collections_b_tail(
const A& a,
const B& b)
46 if constexpr (i < collections::size_of_v<B>)
47 return compare<comp>(Dimensions<1>{}, collections::get<i>(b)) and
48 compare_pattern_collections_b_tail<comp, i + 1>(a, b);
50 return
std::true_type {};
54 template<auto comp, std::
size_t i = 0_uz,
typename A,
typename B>
56 compare_pattern_collections_iter_a(
const A& a,
const B& b)
59 if constexpr (i < collections::size_of_v<A>)
62 return compare<comp>(collections::get<i>(a), collections::get<i>(b)) and
63 compare_pattern_collections_iter_a<comp, i + 1>(a, b);
65 return compare_pattern_collections_a_tail<comp, i>(a, b);
69 for (std::size_t j = i; j < size_b; ++j)
76 template<auto comp, std::
size_t i = 0_uz,
typename A,
typename B>
78 compare_pattern_collections_iter_b(
const A& a,
const B& b)
80 constexpr
auto ix = std::integral_constant<std::size_t, i>{};
82 if constexpr (i < collections::size_of_v<B>)
86 compare_pattern_collections_iter_b<comp, i + 1>(a, b);
88 return compare_pattern_collections_b_tail<comp, i>(a, b);
92 for (std::size_t j = i; j < size_a; ++j)
99 template<auto comp, std::
size_t i = 0_uz,
typename A,
typename B>
101 compare_pattern_collections_iter(
const A& a,
const B& b)
103 constexpr
auto ix = std::integral_constant<std::size_t, i>{};
104 if constexpr (i < collections::size_of_v<A>)
106 if constexpr (i < collections::size_of_v<B>)
108 compare_pattern_collections_iter<comp, i + 1>(a, b);
110 return compare_pattern_collections_a_tail<comp, i>(a, b);
114 return compare_pattern_collections_b_tail<comp, i>(a, b);
127 #ifdef __cpp_concepts 128 template<auto comp = &stdex::is_eq, pattern_collection A, pattern_collection B> requires
129 std::is_invocable_r_v<bool, decltype(comp), stdex::partial_ordering>
130 constexpr OpenKalman::internal::boolean_testable
auto 132 template<
auto comp = &stdex::is_eq,
typename A,
typename B, std::enable_if_t<
133 pattern_collection<A> and pattern_collection<B> and
134 std::is_invocable_r_v<bool, decltype(comp), stdex::partial_ordering>,
int> = 0>
139 if constexpr (pattern_collection_compares_with<A, B, comp, applicability::guaranteed>)
141 return std::true_type {};
143 else if constexpr (not pattern_collection_compares_with<A, B, comp, applicability::permitted> or
144 not collections::sized<A> or not collections::sized<B>)
146 return std::false_type {};
148 else if constexpr (collections::size_of_v<A> == stdex::dynamic_extent and collections::size_of_v<B> == stdex::dynamic_extent)
153 for (; i < size_a and i < size_b; ++i)
155 for (; i < size_a; ++i)
157 for (; i < size_b; ++i)
161 else if constexpr (collections::size_of_v<B> == stdex::dynamic_extent)
163 return detail::compare_pattern_collections_iter_a<comp>(a, b);
165 else if constexpr (collections::size_of_v<A> == stdex::dynamic_extent)
167 return detail::compare_pattern_collections_iter_b<comp>(a, b);
171 return detail::compare_pattern_collections_iter<comp>(a, b);
Definition for pattern_collection.
Definition of the Dimensions class.
Definition for pattern_collection_compares_with.
Definition of coordinates::compare.
The namespace for features relating to coordinates::pattern object.
Definition: compares_with.hpp:25
Inclusion file for collections.
constexpr auto compare_pattern_collections(const A &a, const B &b)
Compare each element of two pattern_collection objects lexicographically.
Definition: compare_pattern_collections.hpp:137
A structure representing the dimensions associated with of a particular index.
Definition: Dimensions.hpp:42
decltype(auto) constexpr get_element(Arg &&arg, I i)
A generalization of std::get and the range subscript operator.
Definition: get_element.hpp:122
constexpr auto get_size(Arg &&arg)
Get the size of a sized object (e.g, a collection)
Definition: get_size.hpp:188