16 #ifndef OPENKALMAN_COLLECTIONS_VIEWS_CONCAT_HPP 17 #define OPENKALMAN_COLLECTIONS_VIEWS_CONCAT_HPP 28 template<std::
size_t i>
29 constexpr
auto concat_tuple_view_indices()
31 return std::pair {std::integral_constant<std::size_t, 0_uz>{}, std::integral_constant<std::size_t, 0_uz>{}};
34 template<std::size_t i,
typename T,
typename...Ts>
35 constexpr
auto concat_tuple_view_indices()
37 constexpr std::size_t
size = size_of_v<T>;
38 if constexpr (i < size)
40 return std::pair {std::integral_constant<std::size_t, 0_uz>{}, std::integral_constant<std::size_t, i>{}};
44 auto [a, b] = concat_tuple_view_indices<i -
size, Ts...>();
45 return std::pair {std::integral_constant<std::size_t, 1_uz + decltype(a)::value>{}, b};
59 template<
typename...Ts>
64 constexpr
concat_tuple_view() requires (... and std::default_initializable<Ts>) =
default;
66 template<
bool Enable =
true, std::enable_if_t<Enable and (... and stdex::default_initializable<Ts>),
int> = 0>
72 template<
typename...Args> requires (... and std::constructible_from<Ts, Args&&>)
74 template<
typename...Args, std::enable_if_t<(... and stdex::constructible_from<Ts, Args&&>),
int> = 0>
76 explicit constexpr
concat_tuple_view(Args&&...args) : tup {std::forward<Args>(args)...} {}
82 #ifdef __cpp_explicit_this_parameter 83 template<std::
size_t i>
84 constexpr decltype(
auto)
85 get(
this auto&&
self) noexcept
87 static_assert(i < (0_uz + ... + size_of_v<Ts>),
"Index out of range");
88 auto [element,
index] = std::decay_t<decltype(detail::concat_tuple_view_indices<i, Ts...>())>();
92 template<std::
size_t i>
93 constexpr decltype(
auto)
96 static_assert(i < (0_uz + ... + size_of_v<Ts>),
"Index out of range");
97 auto [element,
index] = std::decay_t<decltype(detail::concat_tuple_view_indices<i, Ts...>())>();
101 template<std::
size_t i>
102 constexpr decltype(
auto)
105 static_assert(i < (0_uz + ... + size_of_v<Ts>),
"Index out of range");
106 auto [element,
index] = std::decay_t<decltype(detail::concat_tuple_view_indices<i, Ts...>())>();
110 template<std::
size_t i>
111 constexpr decltype(
auto)
114 static_assert(i < (0_uz + ... + size_of_v<Ts>),
"Index out of range");
115 auto [element,
index] = std::decay_t<decltype(detail::concat_tuple_view_indices<i, Ts...>())>();
119 template<std::
size_t i>
120 constexpr decltype(
auto)
121 get()
const && noexcept
123 static_assert(i < (0_uz + ... + size_of_v<Ts>),
"Index out of range");
124 auto [element,
index] = std::decay_t<decltype(detail::concat_tuple_view_indices<i, Ts...>())>();
131 std::tuple<internal::movable_wrapper<Ts>...> tup;
138 template<
typename...Args>
146 template<
typename...Ts>
148 : std::integral_constant<std::size_t, (0 + ... + OpenKalman::collections::size_of_v<Ts>)> {};
151 template<std::size_t i,
typename...Ts>
155 static_assert(i < (0 + ... + OpenKalman::collections::size_of_v<Ts>));
156 using indices = decltype(OpenKalman::collections::detail::concat_tuple_view_indices<i, Ts...>());
172 #ifdef __cpp_concepts 175 template<
typename...R, std::enable_if_t<(
sizeof...(R) > 0) and (... and viewable_collection<R>),
int> = 0>
177 constexpr decltype(
auto)
178 operator() (R&&...r)
const 180 if constexpr (
sizeof...(R) == 1)
181 return all(std::forward<R>(r)...);
182 else if constexpr ((... and (uniformly_gettable<R>)))
Namespace for collections.
Definition: collections.hpp:27
constexpr bool uniformly_gettable
T is a fixed-size object that is gettable for all indices.
Definition: uniformly_gettable.hpp:55
constexpr detail_get::get_impl< i > get
A generalization of std::get, where the index is known at compile time.
Definition: get.hpp:50
Header file for code relating to values (e.g., scalars and indices)
A view to a concatenation of some number of other uniformly_gettable object.
Definition: concat.hpp:61
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
constexpr bool viewable_collection
A std::range or viewable_tuple_like object that can be converted into a collection_view by passing it...
Definition: viewable_collection.hpp:32
concat_tuple_view(Args &&...) -> concat_tuple_view< Args... >
Deduction guide.
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated pattern objects.
Definition: concat.hpp:56
constexpr bool size
T is either an index representing a size, or unbounded_size_t, which indicates that the size is unbou...
Definition: size.hpp:65
Namespace for generalized views.
Definition: collections.hpp:33
Definition: concat.hpp:170
typename collection_element< i, T >::type collection_element_t
Helper template for collection_element.
Definition: collection_element.hpp:116
decltype(auto) constexpr get_element(Arg &&arg, I i)
A generalization of std::get and the range subscript operator.
Definition: get_element.hpp:122
Definition for collections::collection_element.
constexpr bool index
An object describing a collection of /ref values::index objects.
Definition: index.hpp:77