OpenKalman
uniformly_gettable.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_UNIFORMLY_GETTABLE_HPP
17 #define OPENKALMAN_COLLECTIONS_UNIFORMLY_GETTABLE_HPP
18 
19 #include "gettable.hpp"
21 
23 {
24 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L
25  namespace detail
26  {
28  struct uniformly_gettable_sized_impl : std::false_type {};
29 
30  template<typename T, std::size_t...i>
31  struct uniformly_gettable_sized_impl<T, std::index_sequence<i...>> : std::bool_constant<(... and gettable<i, T>)> {};
32 
33 
34  template<typename T, typename = void>
35  struct uniformly_gettable_sized : std::false_type {};
36 
37  template<typename T>
38  struct uniformly_gettable_sized<T, std::enable_if_t<size_of<T>::value != stdex::dynamic_extent>>
39  : uniformly_gettable_sized_impl<T> {};
40 
41  }
42 #endif
43 
44 
48  template<typename T>
49 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L
50  concept uniformly_gettable =
51  sized<T> and
52  (size_of_v<T> != stdex::dynamic_extent) and
53  []<std::size_t...i>(std::index_sequence<i...>) { return (... and gettable<i, T>); } (std::make_index_sequence<size_of_v<T>>{});
54 #else
55  inline constexpr bool uniformly_gettable =
56  sized<T> and
58 #endif
59 
60 
61 }
62 
63 #endif
Namespace for collections.
Definition: collections.hpp:27
constexpr bool uniformly_gettable
T is a fixed-size object that is gettable for all indices.
Definition: uniformly_gettable.hpp:55
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: trait_backports.hpp:64
Definition for collections::gettable.