OpenKalman
fixed_pattern_tuple.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_COORDINATE_FIXED_PATTERN_TUPLE_HPP
17 #define OPENKALMAN_COORDINATE_FIXED_PATTERN_TUPLE_HPP
18 
19 #include <type_traits>
20 #include <tuple>
23 #include "fixed_pattern.hpp"
24 
26 {
27 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L
28  namespace detail
29  {
30  template<typename T, std::size_t...Ix>
31  constexpr bool is_fixed_pattern_tuple_impl(std::index_sequence<Ix...>)
32  {
33  return (... and fixed_pattern<std::tuple_element_t<Ix, T>>);
34  }
35 
36  template<typename T, typename = void>
37  struct is_fixed_pattern_tuple : std::false_type {};
38 
39  template<typename T>
40  struct is_fixed_pattern_tuple<T, std::enable_if_t<tuple_like<T>>>
41  : std::bool_constant<is_fixed_pattern_tuple_impl<T>(std::make_index_sequence<std::tuple_size_v<T>>{})> {};
42 
43  } // namespace detail
44 #endif
45 
46 
50  template<typename T>
51 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L
52  concept fixed_pattern_tuple =
53  pattern_tuple<T> and
54  []<std::size_t...Ix>(std::index_sequence<Ix...>)
55  { return (... and fixed_pattern<std::tuple_element_t<Ix, std::decay_t<T>>>); }
56  (std::make_index_sequence<std::tuple_size_v<std::decay_t<T>>>{});
57 #else
58  constexpr bool fixed_pattern_tuple =
59  detail::is_fixed_pattern_tuple<std::decay_t<T>>::value;
60 #endif
61 
62 
63 } // namespace OpenKalman::coordinates
64 
65 #endif //OPENKALMAN_COORDINATE_FIXED_PATTERN_TUPLE_HPP
Definition for collections::tuple_like.
Definition: tuple_reverse.hpp:103
Definition for coordinates::fixed_pattern.
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definition: compares_with.hpp:28
constexpr bool fixed_pattern_tuple
An object describing a tuple-like collection of /ref coordinates::pattern objects.
Definition: fixed_pattern_tuple.hpp:58
Definition for pattern_tuple.