OpenKalman
dynamic_index_count.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) 2023-2024 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_DYNAMIC_INDEX_COUNT_HPP
17 #define OPENKALMAN_DYNAMIC_INDEX_COUNT_HPP
18 
21 
22 namespace OpenKalman
23 {
24  namespace detail
25  {
26  template<typename T, std::size_t...I>
27  constexpr std::size_t dynamic_index_count_impl(std::index_sequence<I...>)
28  {
29  return ((index_dimension_of_v<T, I> == stdex::dynamic_extent ? 1 : 0) + ... + 0);
30  }
31  }
32 
33 
38 #ifdef __cpp_concepts
39  template<typename T>
40 #else
41  template<typename T, typename = void>
42 #endif
44 
45 
50 #ifdef __cpp_concepts
51  template<indexible T>
52  struct dynamic_index_count<T>
53 #else
54  template<typename T>
55  struct dynamic_index_count<T, std::enable_if_t<indexible<T>>>
56 #endif
57  : std::integral_constant<std::size_t, detail::dynamic_index_count_impl<T>(std::make_index_sequence<index_count_v<T>> {})> {};
58 
59 
63 #ifdef __cpp_concepts
64  template<indexible T>
65 #else
66  template<typename T>
67 #endif
68  static constexpr std::size_t dynamic_index_count_v = dynamic_index_count<T>::value;
69 
70 
71 }
72 
73 #endif
Counts the number of indices of T in which the dimensions are dynamic.
Definition: dynamic_index_count.hpp:43
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition for index_dimension_of.
Definition for index_count.
Definition: trait_backports.hpp:64