OpenKalman
common_descriptor_type.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_COLLECTIONS_COMMON_DESCRIPTOR_TYPE_HPP
17 #define OPENKALMAN_COLLECTIONS_COMMON_DESCRIPTOR_TYPE_HPP
18 
25 
27 {
35 #ifdef __cpp_concepts
36  template<typename T>
37 #else
38  template<typename T, typename = void, typename = void>
39 #endif
41 
42 
44 #ifdef __cpp_concepts
45  template<descriptor T>
46  struct common_descriptor_type<T>
47 #else
48  template<typename T>
49  struct common_descriptor_type<T, std::enable_if_t<descriptor<T>>>
50 #endif
51  : std::conditional_t<
52  euclidean_pattern<T>,
53  stdex::type_identity<Dimensions<1>>,
54  stdex::type_identity<std::decay_t<T>>
55  > {};
56 
57 
58  namespace detail
59  {
60  template<typename...Ts>
62 
63  template<typename T>
65 
66  template<typename T0, typename T1, typename...Ts>
67  struct common_descriptor_type_iter<T0, T1, Ts...>
68  : std::conditional_t<dimension_of_v<T0> == 0 and dimension_of_v<T1> == 0, common_descriptor_type_iter<Ts...>,
69  std::conditional_t<dimension_of_v<T0> == 0, common_descriptor_type_iter<T1, Ts...>,
70  std::conditional_t<dimension_of_v<T1> == 0, common_descriptor_type_iter<T0, Ts...>,
71  common_descriptor_type_iter<
72  typename std::conditional_t<stdex::common_reference_with<T0, T1>, stdex::common_reference<T0, T1>,
73  stdex::type_identity<Any<>>
74  >::type, Ts...>
75  >>> {};
76 
77 
80 
81  template<typename T, std::size_t...i>
82  struct common_descriptor_type_expand<T, std::index_sequence<i...>>
83  : common_descriptor_type_iter<collections::collection_element_t<i, T>...> {};
84 
85 
86 #ifdef __cpp_concepts
87  template<typename T>
88 #else
89  template<typename T, typename = void>
90 #endif
92 
93 
94 #ifdef __cpp_concepts
95  template<collections::uniformly_gettable T> requires (not stdex::ranges::random_access_range<T>)
97 #else
98  template<typename T>
100  std::enable_if_t<collections::uniformly_gettable<T> and not stdex::ranges::random_access_range<T>>>
101 #endif
103 
104  }
105 
106 
108 #ifdef __cpp_concepts
109  template<descriptor_collection T>
110  struct common_descriptor_type<T>
111 #else
112  template<typename T>
113  struct common_descriptor_type<T, std::enable_if_t<descriptor_collection<T>>>
114 #endif
115  : std::conditional_t<
116  euclidean_pattern<T>,
117  stdex::type_identity<Dimensions<1>>,
118  detail::common_descriptor_type_impl<T>
119  > {};
120 
121 
125  template<typename T>
127 
128 }
129 
130 #endif
Definition for coordinates::euclidean_pattern.
typename common_descriptor_type< T >::type common_descriptor_type_t
Helper template for common_descriptor_type.
Definition: common_descriptor_type.hpp:126
The common type within a pattern, if it exists.
Definition: common_descriptor_type.hpp:40
Definition of the Dimensions class.
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition for coordinates::descriptor.
The namespace for features relating to coordinates::pattern object.
Definition: compares_with.hpp:25
Inclusion file for collections.
Definition: common_descriptor_type.hpp:61
Definition: common_descriptor_type.hpp:91
Definition: language-features.hpp:243
The common type within a collection, if it exists.
Definition: common_collection_type.hpp:34
Definition for coordinates::descriptor_collection.
Definition for coordinates::dimension_of.