16 #ifndef OPENKALMAN_COORDINATES_WRAP_HPP 17 #define OPENKALMAN_COORDINATES_WRAP_HPP 19 #include <type_traits> 22 #include "coordinates/interfaces/coordinate_descriptor_traits.hpp" 32 #ifndef __cpp_concepts 35 template<
typename Traits,
typename =
void>
38 template<
typename Traits>
53 template<descriptor T, collections::collection R>
56 template<
typename T,
typename R, std::enable_if_t<descriptor<T> and collections::collection<R>,
int> = 0>
57 constexpr decltype(
auto)
59 wrap(
const T& t, R&& data_view)
61 if constexpr (dimension_of_v<T> != stdex::dynamic_extent and collections::size_of_v<R> != stdex::dynamic_extent)
62 static_assert(dimension_of_v<T> == collections::size_of_v<R>);
64 if constexpr (euclidean_pattern<T>)
66 return std::forward<R>(data_view);
70 using U = std::decay_t<stdex::unwrap_ref_decay_t<T>>;
78 if constexpr (std::is_same_v<U, T>)
79 return stdex::invoke(
Traits::wrap, t, std::forward<R>(data_view));
81 return stdex::invoke(
Traits::wrap, t.get(), std::forward<R>(data_view));
93 template<std::size_t t_i = 0, std::size_t data_view_i = 0,
typename T,
typename R,
typename...Out>
95 wrap_tuple(
const T& t,
const R& data_view, Out...out)
97 if constexpr (t_i < collections::size_of_v<T>)
99 decltype(
auto) t_elem = collections::get<t_i>(t);
102 auto o =
wrap(t_elem, std::move(data_view_sub));
103 return wrap_tuple<t_i + 1, data_view_i + values::fixed_value_of_v<decltype(dim)>>(t, data_view, std::move(out)..., std::move(o));
122 #ifdef __cpp_concepts 123 template<descriptor_collection T, collections::collection R>
126 template<
typename T,
typename R, std::enable_if_t<descriptor_collection<T> and collections::collection<R>,
int> = 0>
127 constexpr decltype(
auto)
129 wrap(
const T& t, R&& data_view)
131 if constexpr (dimension_of_v<T> != stdex::dynamic_extent and collections::size_of_v<R> != stdex::dynamic_extent)
132 static_assert(dimension_of_v<T> == collections::size_of_v<R>);
134 if constexpr (dimension_of_v<T> == stdex::dynamic_extent)
136 std::vector<collections::common_collection_type_t<R>> data;
142 #if __cpp_lib_containers_ranges >= 202002L 146 data.insert(data.end(), sd.cbegin(), sd.cend());
154 return detail::wrap_tuple(t, data_view);
Definition for coordinates::euclidean_pattern.
constexpr bool collection
An object describing a collection of objects.
Definition: collection.hpp:32
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated collection objects.
Definition: concat.hpp:196
decltype(auto) constexpr to_stat_space(const T &t, R &&data_view)
Maps a range reflecting vector-space data to a corresponding range in a vector space for directional ...
Definition: to_stat_space.hpp:44
decltype(auto) constexpr wrap(const T &t, R &&data_view)
wraps a range reflecting vector-space data to its primary range.
Definition: wrap.hpp:59
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 coordinates::to_stat_space.
Definition for collections::from_stat_space.
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
Definition for coordinates::descriptor.
The namespace for features relating to coordinates::pattern object.
Definition: compares_with.hpp:25
Inclusion file for collections.
constexpr detail::slice_adapter slice
a RangeAdapterObject associated with slice_view.
Definition: slice.hpp:364
Traits for coordinates::pattern objects.
Definition: coordinate_descriptor_traits.hpp:36
decltype(auto) constexpr from_stat_space(const T &t, R &&stat_data_view)
Maps a range in a vector space for directional-statistics back to a range reflecting vector-space dat...
Definition: from_stat_space.hpp:44
Definition for coordinates::descriptor_collection.
Definition for coordinates::dimension_of.