OpenKalman
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) 2019-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_COUNT_HPP
17 #define OPENKALMAN_INDEX_COUNT_HPP
18 
19 #include "count_indices.hpp"
20 
21 namespace OpenKalman
22 {
29 #ifdef __cpp_concepts
30  template<typename T>
31 #else
32  template<typename T, typename = void>
33 #endif
34  struct index_count {};
35 
36 
40 #ifdef __cpp_concepts
41  template<indexible T> requires requires(const T& t) { {count_indices(t)} -> values::fixed; }
42  struct index_count<T>
43 #else
44  template<typename T>
45  struct index_count<T, std::enable_if_t<values::fixed<decltype(count_indices(std::declval<const T&>()))>>>
46 #endif
47  : std::integral_constant<std::size_t, values::fixed_value_of_v<decltype(count_indices(std::declval<const T&>()))>> {};
48 
49 
53  template<typename T>
54  static constexpr std::size_t index_count_v = index_count<T>::value;
55 
56 
57 }
58 
59 #endif
constexpr auto count_indices(const T &)
Get the number of indices necessary to address all the components of an indexible object...
Definition: count_indices.hpp:51
Definition of count_indices.
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
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