16 #ifndef OPENKALMAN_GET_COMPONENT_HPP 17 #define OPENKALMAN_GET_COMPONENT_HPP 30 template<
typename Arg,
typename Indices>
31 constexpr decltype(
auto)
32 get_component_impl(Arg&& arg, const Indices& indices)
34 using Trait = interface::library_interface<std::decay_t<Arg>>;
46 #ifdef __cpp_lib_concepts 47 template<indexible Arg, index_range_for<Arg> Indices> requires (not empty_object<Arg>)
48 constexpr values::scalar decltype(
auto)
50 template<
typename Arg,
typename Indices, std::enable_if_t<
51 index_range_for<Indices, Arg> and (not empty_object<Arg>),
int> = 0>
52 constexpr decltype(
auto)
56 return detail::get_component_impl(std::forward<Arg>(arg), indices);
64 #ifdef __cpp_lib_concepts 65 template<indexible Arg, values::index Ix> requires (not empty_object<Arg>)
66 constexpr values::scalar decltype(
auto)
68 template<
typename Arg,
typename Ix, std::enable_if_t<values::index<Ix> and (not empty_
object<Arg>),
int> = 0>
69 constexpr decltype(
auto)
73 return detail::get_component_impl(std::forward<Arg>(arg), indices);
81 template<
typename Arg,
typename...V, std::size_t...Ix>
82 constexpr
bool static_indices_within_bounds_impl(std::index_sequence<Ix...>)
85 if constexpr (values::fixed<V>)
94 template<
typename Arg,
typename...I>
96 : std::bool_constant<(detail::static_indices_within_bounds_impl<Arg, I...>(std::index_sequence_for<I...>{}))> {};
107 #ifdef __cpp_lib_concepts 109 (index_count_v<Arg> ==
dynamic_size or
sizeof...(I) >= index_count_v<Arg>) and
111 constexpr values::scalar decltype(
auto)
113 template<
typename Arg,
typename...I, std::enable_if_t<indexible<Arg> and (... and values::index<I>) and
116 constexpr decltype(
auto)
120 if constexpr (
sizeof...(I) == 0)
121 return detail::get_component_impl(std::forward<Arg>(arg), std::array<std::size_t, 0> {});
123 return detail::get_component_impl(std::forward<Arg>(arg),
124 std::array {
static_cast<std::common_type_t<I...
>>(std::forward<I>(i))...});
130 #endif //OPENKALMAN_GET_COMPONENT_HPP constexpr auto count_indices(const T &t)
Get the number of indices available to address the components of an indexible object.
Definition: count_indices.hpp:33
Definition for values::index.
constexpr bool indexible
T is a generalized tensor type.
Definition: indexible.hpp:32
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: get_component.hpp:95
Forward declaration of library_interface, which must be defined for all objects used in OpenKalman...
Definition for index_range_for.
Definition for empty_object.
constexpr bool index
T is an index value.
Definition: index.hpp:56
decltype(auto) constexpr get_component(Arg &&arg, const Indices &indices)
Get a component of an object at a particular set of indices.
Definition: get_component.hpp:54
decltype(auto) constexpr get_component(Arg &&arg, I &&...i)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: get_component.hpp:118
The minimum number of indices need to access all the components of an object.
Definition: index_count.hpp:33
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33