OpenKalman
index_collection_for.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2024-2025 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_INDEX_COLLECTION_FOR_HPP
17 #define OPENKALMAN_INDEX_COLLECTION_FOR_HPP
18 
19 #include "coordinates/coordinates.hpp"
22 
23 namespace OpenKalman
24 {
25  namespace detail
26  {
27  template<typename Indices, typename T, typename Seq = std::make_index_sequence<collections::size_of_v<Indices>>>
28  struct index_collection_for_iter : std::false_type {};
29 
30  template<typename Indices, typename T, std::size_t...ix>
31  struct index_collection_for_iter<Indices, T, std::index_sequence<ix...>>
32  : std::bool_constant<(... and (not values::size_compares_with<
33  collections::collection_element_t<ix, Indices>,
34  index_dimension_of<T, ix>,
35  &stdex::is_gteq
36  >))> {};
37 
38 
39 #ifndef __cpp_concepts
40  template<typename Indices, typename Indexible, typename = void>
41  struct index_collection_for_impl : std::true_type {};
42 
43  template<typename Indices, typename Indexible>
44  struct index_collection_for_impl<Indices, Indexible, std::enable_if_t<
45  values::fixed_value_compares_with<collections::size_of<Indices>, stdex::dynamic_extent, &stdex::is_neq>>>
46  : index_collection_for_iter<Indices, Indexible> {};
47 #endif
48  }
49 
50 
55  template<typename Indices, typename T>
56 #ifdef __cpp_concepts
57  concept index_collection_for =
58  collections::index<Indices> and
59  indexible<T> and
63 #else
64  constexpr bool index_collection_for =
65  collections::index<Indices> and
66  indexible<T> and
68  detail::index_collection_for_impl<Indices, T>::value;
69 #endif
70 
71 }
72 
73 #endif
The size of a sized object (including a collection).
Definition: size_of.hpp:33
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: index_collection_for.hpp:28
Definition for index_dimension_of.
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
Definition for index_count.
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74
Definition: index_collection_for.hpp:41
The minimum number of indices needed to access all the components of an object (i.e., the rank or order).
Definition: index_count.hpp:34
constexpr bool index_collection_for
Indices is a collection of indices that are compatible with indexible object T.
Definition: index_collection_for.hpp:64