OpenKalman
uniformly_settable.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_SETTABLE_HPP
17 #define OPENKALMAN_COLLECTIONS_UNIFORMLY_SETTABLE_HPP
18 
19 #include "values/values.hpp"
20 #include "settable.hpp"
22 
24 {
25 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L
26  namespace detail
27  {
28  template<typename C, typename T, typename = std::make_index_sequence<size_of_v<C>>, typename = void>
29  struct uniformly_settable_sized_impl : std::false_type {};
30 
31  template<typename C, typename T, std::size_t...i>
32  struct uniformly_settable_sized_impl<C, T, std::index_sequence<i...>, std::enable_if_t<(... and settable<i, C, T>)>>
33  : std::true_type {};
34 
35 
36  template<typename C, typename T, typename = void>
37  struct uniformly_settable_sized : std::false_type {};
38 
39  template<typename C, typename T>
40  struct uniformly_settable_sized<C, T, std::enable_if_t<size_of<C>::value != stdex::dynamic_extent>>
41  : uniformly_settable_sized_impl<C, T> {};
42  }
43 #endif
44 
45 
50  template<typename C, typename T>
51 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L
52  concept uniformly_settable =
53  ((sized<C> and size_of_v<C> != stdex::dynamic_extent) or settable<0_uz, C, T>) and
54  (not sized<C> or size_of_v<C> == stdex::dynamic_extent or
55  []<std::size_t...i>(std::index_sequence<i...>) { return (... and settable<i, C, T>); }
56  (std::make_index_sequence<size_of_v<C>>{}));
57 #else
58  constexpr bool uniformly_settable =
59  ((sized<C> and not values::fixed_value_compares_with<size_of<C>, stdex::dynamic_extent>) or settable<0_uz, C, T>) and
60  (not sized<C> or size_of_v<C> == stdex::dynamic_extent or
62 #endif
63 
64 
65 }
66 
67 #endif
Namespace for collections.
Definition: collections.hpp:27
Header file for code relating to values (e.g., scalars and indices)
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 for collections::settable.
Definition: trait_backports.hpp:64
constexpr bool uniformly_settable
C is settable with type C for all indices.
Definition: uniformly_settable.hpp:58