OpenKalman
get_descriptor_stat_dimension.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) 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 
17 #ifndef OPENKALMAN_GET_DESCRIPTOR_EUCLIDEAN_SIZE_HPP
18 #define OPENKALMAN_GET_DESCRIPTOR_EUCLIDEAN_SIZE_HPP
19 
21 #include "coordinates/interfaces/coordinate_descriptor_traits.hpp"
23 
25 {
31 #ifdef __cpp_concepts
32  template<descriptor Arg>
33  constexpr values::index decltype(auto)
34 #else
35  template<typename Arg, std::enable_if_t<descriptor<Arg>, int> = 0>
36  constexpr decltype(auto)
37 #endif
38  get_descriptor_stat_dimension(Arg&& arg)
39  {
40  if constexpr (values::index<Arg>)
41  {
42  return values::cast_to<std::size_t>(std::forward<Arg>(arg));
43  }
44  else
45  {
46  using U = std::decay_t<stdex::unwrap_ref_decay_t<Arg>>;
47  using Traits = interface::coordinate_descriptor_traits<U>;
48  if constexpr (std::is_same_v<U, std::decay_t<Arg>>) return Traits::stat_dimension(std::forward<Arg>(arg));
49  else return Traits::stat_dimension(std::forward<Arg>(arg).get());
50  }
51  }
52 
53 
54 }
55 
56 
57 #endif
Definition for values::index.
constexpr detail_get::get_impl< i > get
A generalization of std::get, where the index is known at compile time.
Definition: get.hpp:50
Definition: get_descriptor_dimension.hpp:25
Definition for coordinates::descriptor.
constexpr bool index
T is an index value.
Definition: index.hpp:62