16 #ifndef OPENKALMAN_COLLECTIONS_GET_ELEMENT_HPP 17 #define OPENKALMAN_COLLECTIONS_GET_ELEMENT_HPP 21 #include "collections/traits/std-extents.hpp" 29 template<
typename T,
typename I>
31 template<
typename T,
typename I,
typename =
void>
39 template<typename T, typename I>
48 template<
typename T,
typename I>
50 template<
typename T,
typename I,
typename =
void>
58 template<typename T, typename I>
59 struct
has_adl_get_function<T, I, std::void_t<decltype(get<values::fixed_value_of<I>::value>(std::declval<T>()))>>
64 template<
typename Arg,
typename I>
65 constexpr decltype(
auto)
66 get_element_impl(Arg&& arg, I ix)
70 return std::forward<Arg>(arg).
template get<values::fixed_value_of_v<I>>();
74 return get<values::fixed_value_of_v<I>>(std::forward<Arg>(arg));
79 if constexpr (std::is_array_v<stdex::remove_cvref_t<Arg>>)
81 return std::forward<Arg>(arg)[n];
83 else if constexpr (stdex::ranges::borrowed_range<Arg>)
85 return stdex::ranges::begin(std::forward<Arg>(arg))[n];
90 return begin(std::forward<Arg>(arg))[n];
110 #ifdef __cpp_concepts 111 template<
typename Arg, values::index I> requires
113 (stdex::ranges::random_access_range<Arg> or
117 template<
typename Arg,
typename I, std::enable_if_t<values::index<I> and
118 (not values::size_compares_with<I, size_of<Arg>, &stdex::is_gteq>) and
119 (stdex::ranges::random_access_range<Arg> or
120 detail_get::has_member_get_function<Arg, I>::value or
121 detail_get::has_adl_get_function<Arg, I>::value),
int> = 0>
123 constexpr decltype(
auto)
126 return detail_get::get_element_impl(std::forward<Arg>(arg), i);
Namespace for collections.
Definition: collections.hpp:27
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)
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 collections::size_of.
The size of a sized object (including a collection).
Definition: size_of.hpp:33
The fixed value associated with a fixed.
Definition: fixed_value_of.hpp:44
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition: get_element.hpp:33
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
decltype(auto) constexpr get_element(Arg &&arg, I i)
A generalization of std::get and the range subscript operator.
Definition: get_element.hpp:124
Definition: get_element.hpp:52