16 #ifndef OPENKALMAN_GET_UNIFORM_PATTERN_COMPONENT_HPP 17 #define OPENKALMAN_GET_UNIFORM_PATTERN_COMPONENT_HPP 23 #include "coordinates/descriptors/Any.hpp" 31 template<
typename A,
typename T, std::size_t i, std::size_t...is>
35 auto t0 = collections::get<i>(t);
36 if ((... and
compare(t0, collections::get<is>(t))))
37 return std::optional {A{t0}};
39 return std::optional<A> {};
60 template<
typename T, std::enable_if_t<pattern<T>,
int> = 0>
65 if constexpr (euclidean_pattern<T>)
69 else if constexpr (descriptor<T>)
71 if constexpr (dimension_of_v<T> == 1)
72 return std::optional {std::forward<T>(t)};
74 return std::optional<std::decay_t<T>>{};
80 if constexpr (dimension_of_v<C> == 1)
82 return std::optional {C{}};
84 else if constexpr (dimension_of_v<C> != stdex::dynamic_extent or not collections::sized<T>)
86 return std::optional<A>{};
88 else if constexpr (collections::size_of_v<T> == 0)
90 return std::optional<C>{};
92 else if constexpr (collections::size_of_v<T> == stdex::dynamic_extent)
96 auto pred = [](
const auto& x,
const auto& y) ->
bool {
return compare<stdex::is_neq>(x, y); };
97 #ifdef __cpp_lib_ranges 98 if (std::ranges::adjacent_find(v, pred) == v.end())
return std::optional {A{v.front()}};
100 if (std::adjacent_find(v.begin(), v.end(), pred) == v.end())
return std::optional {A{v.front()}};
102 return std::optional<A>{};
106 return detail::equal_tuple_elements<A>(t, std::make_index_sequence<collections::size_of_v<T>>{});
typename common_descriptor_type< T >::type common_descriptor_type_t
Helper template for common_descriptor_type.
Definition: common_descriptor_type.hpp:126
Definition: get_uniform_pattern_component.hpp:44
constexpr auto compare(const A &a, const B &b)
Compare two coordinates::pattern objects lexicographically.
Definition: compare.hpp:40
constexpr auto get_uniform_pattern_component(T &&t)
If the argument is a uniform pattern, return the 1D component that can be replicated to produce the a...
Definition: get_uniform_pattern_component.hpp:63
Definition for coordinates::pattern.
Definition of coordinates::compare.
constexpr auto get_is_euclidean(const Arg &arg)
Determine, whether coordinates::pattern Arg is euclidean.
Definition: get_is_euclidean.hpp:65
The namespace for features relating to coordinates::pattern object.
Definition: compares_with.hpp:25
constexpr detail::all_closure all
a std::ranges::range_adaptor_closure which returns a view to all members of its collection argument...
Definition: all.hpp:72
Inclusion file for collections.
A structure representing the dimensions associated with of a particular index.
Definition: Dimensions.hpp:42
Definition: trait_backports.hpp:64
Definition for collections::common_descriptor_type.