OpenKalman
descriptor_collection.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_GROUP_COLLECTION_HPP
17 #define OPENKALMAN_COORDINATES_GROUP_COLLECTION_HPP
18 
20 #include "descriptor.hpp"
21 
23 {
24 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L or not defined(__cpp_lib_ranges)
25  namespace detail
26  {
27  template<typename T, typename = void>
28  struct is_descriptor_range : std::false_type {};
29 
30  template<typename T>
31  struct is_descriptor_range<T, std::enable_if_t<descriptor<stdex::ranges::range_value_t<T>>>> : std::true_type {};
32 
33 
34  template<typename T>
35  constexpr bool descriptor_range =
36  stdex::ranges::random_access_range<T> and is_descriptor_range<T>::value;
37 
38 
39  template<typename T, std::size_t...Ix>
40  constexpr bool is_descriptor_tuple_impl(std::index_sequence<Ix...>)
41  {
42  return (... and descriptor<collections::collection_element_t<Ix, T>>);
43  }
44 
45  template<typename T, typename = void>
46  struct is_descriptor_tuple : std::false_type {};
47 
48  template<typename T>
49  struct is_descriptor_tuple<T, std::enable_if_t<collections::uniformly_gettable<T>>>
50  : std::bool_constant<is_descriptor_tuple_impl<T>(std::make_index_sequence<collections::size_of_v<T>>{})> {};
51 
52 
53  template<typename T>
54  inline constexpr bool descriptor_tuple = is_descriptor_tuple<std::decay_t<T>>::value;
55  }
56 #endif
57 
58 
63  template<typename T>
64 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L and defined(__cpp_lib_ranges)
65  concept descriptor_collection =
66  (std::ranges::random_access_range<T> and descriptor<std::ranges::range_value_t<T>>) or
67  (collections::uniformly_gettable<T> and
68  []<std::size_t...Ix>(std::index_sequence<Ix...>)
69  { return (... and descriptor<collections::collection_element_t<Ix, T>>); }
70  (std::make_index_sequence<collections::size_of_v<T>>{}));
71 #else
72  constexpr bool descriptor_collection =
73  detail::descriptor_range<T> or
74  detail::descriptor_tuple<T>;
75 #endif
76 
77 
78 }
79 
80 #endif
constexpr bool descriptor_collection
An object describing a collection of /ref coordinates::descriptor objects.
Definition: descriptor_collection.hpp:72
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.
constexpr bool descriptor
T is an atomic (non-separable or non-composite) grouping of coordinates::pattern objects.
Definition: descriptor.hpp:31
Definition: trait_backports.hpp:64