16 #ifndef OPENKALMAN_COLLECTIONS_INDEX_HPP 17 #define OPENKALMAN_COLLECTIONS_INDEX_HPP 19 #include <type_traits> 20 #ifdef __cpp_lib_ranges 25 #include "../../basics/compatibility/language-features.hpp" 31 #if not defined(__cpp_lib_ranges) or not defined(__cpp_lib_remove_cvref) or __cpp_generic_lambdas < 201707L 32 namespace detail_index
34 template<
typename T, std::size_t...Ix>
35 constexpr
bool is_index_tuple_impl(std::index_sequence<Ix...>) {
return (... and
values::index<
typename std::tuple_element<Ix, T>::type>); }
37 template<
typename T,
typename =
void>
38 struct is_index_tuple : std::false_type {};
41 struct is_index_tuple<T,
std::enable_if_t<tuple_like<T>>>
42 : std::bool_constant<is_index_tuple_impl<T>(std::make_index_sequence<std::tuple_size_v<T>>{})> {};
45 #ifdef __cpp_lib_remove_cvref 46 using std::remove_cvref_t;
48 #ifdef __cpp_lib_ranges 49 namespace ranges = std::ranges;
53 template<
typename T,
typename =
void>
54 struct is_index_range : std::false_type {};
57 struct is_index_range<T, std::enable_if_t<values::index<ranges::range_value_t<remove_cvref_t<T>>>>> : std::true_type {};
68 #if defined(__cpp_lib_ranges) and defined(__cpp_lib_remove_cvref) and __cpp_generic_lambdas >= 201707L 69 concept
index = collection<T> and
70 ([]<std::size_t...Ix>(std::index_sequence<Ix...>)
71 {
return (... and
values::index<std::tuple_element_t<Ix, std::remove_cvref_t<T>>>); }
72 (std::make_index_sequence<std::tuple_size<std::remove_cvref_t<T>>
::value>{}) or
73 values::index<std::ranges::range_value_t<std::remove_cvref_t<T>>>);
75 constexpr
bool index = collection<T> and
76 (detail_index::is_index_tuple<std::decay_t<T>>::
value or detail_index::is_index_range<std::decay_t<T>>::
value);
81 #endif //OPENKALMAN_COLLECTIONS_INDEX_HPP Namespace for collections.
Definition: collections.hpp:27
Definition for collections::collection.
Header file for code relating to values (e.g., scalars and indices)
Definition: tuple_reverse.hpp:103
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definitions implementing features of the c++ ranges library for compatibility.
constexpr bool index
T is an index value.
Definition: index.hpp:56
constexpr bool index
An object describing a collection of /ref values::index objects.
Definition: index.hpp:75