OpenKalman
common_collection_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_COLLECTION_TYPE_HPP
17 #define OPENKALMAN_COLLECTIONS_COMMON_COLLECTION_TYPE_HPP
18 
19 #include "basics/basics.hpp"
23 
25 {
29 #ifdef __cpp_concepts
30  template<typename T>
31 #else
32  template<typename T, typename = void>
33 #endif
35 
36 
38 #ifdef __cpp_concepts
39  template<stdex::ranges::random_access_range T>
40  struct common_collection_type<T>
41 #else
42  template<typename T>
43  struct common_collection_type<T, std::enable_if_t<stdex::ranges::random_access_range<T>>>
44 #endif
45  {
46  using type = stdex::ranges::range_value_t<stdex::remove_cvref_t<T>>;
47  };
48 
49 
50  namespace detail
51  {
53  struct common_tuple_type {};
54 
55  template<typename T, std::size_t...i>
56  struct common_tuple_type<T, std::index_sequence<i...>>
57  : stdex::common_reference<collection_element_t<i, T>...> {};
58  }
59 
60 
62 #ifdef __cpp_concepts
63  template<uniformly_gettable T> requires (not stdex::ranges::random_access_range<T>)
64  struct common_collection_type<T>
65 #else
66  template<typename T>
68  std::enable_if_t<uniformly_gettable<T> and not stdex::ranges::random_access_range<T>>>
69 #endif
71 
72 
76 #ifdef __cpp_concepts
77  template<collection T>
78 #else
79  template<typename T>
80 #endif
82 
83 }
84 
85 #endif
Namespace for collections.
Definition: collections.hpp:27
Definition for collections::collection.
Definition: common_collection_type.hpp:53
typename common_collection_type< T >::type common_collection_type_t
Helper template for common_collection_type.
Definition: common_collection_type.hpp:81
Definition for collections::size_of.
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition: common.hpp:102
Basic definitions for OpenKalman as a whole.
The common type within a collection, if it exists.
Definition: common_collection_type.hpp:34
Definition for collections::collection_element.