OpenKalman
get_wrappable.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) 2022-2023 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_GET_WRAPPABLE_HPP
17 #define OPENKALMAN_GET_WRAPPABLE_HPP
18 
19 
20 namespace OpenKalman
21 {
22  namespace detail
23  {
24  template<typename T, std::size_t...I>
25  constexpr bool get_wrappable_impl(const T& t, std::index_sequence<I...>)
26  {
27  return (get_is_euclidean(get_pattern_collection<I + 1>(t)) and ...);
28  }
29  }
30 
31 
38 #ifdef __cpp_concepts
39  template<interface::count_indices_defined_for T>
40 #else
41  template<typename T, std::enable_if_t<interface::count_indices_defined_for<T>, int> = 0>
42 #endif
43  constexpr bool get_wrappable(const T& t)
44  {
45  if constexpr (values::fixed<decltype(count_indices(t))>)
46  {
47  constexpr std::size_t count = std::decay_t<decltype(count_indices(t))>::value;
48  return detail::get_wrappable_impl(t, std::make_index_sequence<count - 1> {});
49  }
50  else
51  {
52  for (std::size_t i = 1; i < count_indices(t); ++i)
53  if (not get_is_euclidean(get_pattern_collection(t, i))) return false;
54  return true;
55  }
56  }
57 
58 
59 }
60 
61 #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
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the coordinates::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:59
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
constexpr auto get_is_euclidean(const Arg &arg)
Determine, whether coordinates::pattern Arg is euclidean.
Definition: get_is_euclidean.hpp:65
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: trait_backports.hpp:64
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
constexpr bool get_wrappable(const T &t)
Determine whether T is wrappable (i.e., all its dimensions other than potentially 0 are euclidean)...
Definition: get_wrappable.hpp:43