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