16 #ifndef OPENKALMAN_PATTERNS_GET_COMMON_PATTERN_COLLECTION_DIMENSION_HPP 17 #define OPENKALMAN_PATTERNS_GET_COMMON_PATTERN_COLLECTION_DIMENSION_HPP 31 #ifndef __cpp_concepts 32 template<
typename T,
typename =
void>
41 template<std::
size_t n, std::
size_t i = 0,
typename T>
43 collection_patterns_have_same_dimension_impl(
const T& t)
46 if constexpr (i + 1 < n)
48 auto tail = collection_patterns_have_same_dimension_impl<n, i + 1>(t);
49 using tail_type =
typename decltype(tail)::value_type;
52 return std::optional {d0};
54 return std::optional<std::size_t> {d0};
56 return std::optional<std::size_t> {};
58 else return std::optional {d0};
73 template<auto N = values::unbounded_size, pattern_collection T> requires
83 constexpr
bool has_fixed_common =
85 requires { requires fixed_pattern<collections::common_collection_type_t<T>>; };
90 if constexpr (collections::sized<T>)
93 auto n = [](
const T& t){
101 return std::integral_constant<std::size_t, N>{};
103 using n_type = decltype(n);
105 if constexpr (values::fixed<n_type>)
110 return detail::collection_patterns_have_same_dimension_impl<values::fixed_value_of_v<n_type>>(t);
114 using Op = std::optional<std::size_t>;
122 if constexpr (has_fixed_common)
125 return std::optional<std::size_t> {};
Definition for pattern_collection.
The size of a patterns::pattern.
Definition: dimension_of.hpp:36
constexpr auto get_size(Arg &&arg)
Get the size of a sized object (e.g, a collection)
Definition: get_size.hpp:224
decltype(auto) constexpr get_pattern(P &&p, I i)
Get a pattern within a pattern_collection.
Definition: get_pattern.hpp:39
Definition: get_common_pattern_collection_dimension.hpp:33
decltype(auto) constexpr to_value_type(Arg &&arg)
Convert, if necessary, a fixed or dynamic value to its underlying base type.
Definition: to_value_type.hpp:28
Definition for patterns::get_pattern.
Definition for patterns::fixed_pattern.
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
The namespace for features relating to patterns::pattern object.
Definition: collection_compares_with.hpp:24
constexpr auto get_common_pattern_collection_dimension(const T &t)
Queries whether the first N elements of a pattern_collection have the same dimensions.
Definition: get_common_pattern_collection_dimension.hpp:81
Inclusion file for collections.
A type reflecting an unbound size.
Definition: size.hpp:27
constexpr bool size_compares_with
T and U are sizes that compare in a particular way based on parameter comp.
Definition: size_compares_with.hpp:98
constexpr bool integral
T is an integral value.
Definition: integral.hpp:47
Definition for patterns::get_dimension.
constexpr unbounded_size_t unbounded_size
An instance of unbounded_size_t;.
Definition: size.hpp:60
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of patterns::pattern Arg.
Definition: get_dimension.hpp:53
Definition for patterns::dimension_of.