OpenKalman
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_SETTABLE_HPP
17 #define OPENKALMAN_COLLECTIONS_SETTABLE_HPP
18 
19 #include <tuple>
21 #include "sized.hpp"
23 
25 {
26 #ifndef __cpp_concepts
27  namespace detail
28  {
29  template<std::size_t i, typename C, typename = void>
30  struct settable_impl1 : std::false_type {};
31 
32  template<std::size_t i, typename C>
33  struct settable_impl1<i, C, std::enable_if_t<sized<C>>> : std::bool_constant<(i < size_of_v<C>)> {};
34 
35  template<std::size_t i, typename C, typename T, typename = void>
36  struct settable_impl2 : std::false_type {};
37 
38  template<std::size_t i, typename C, typename T>
39  struct settable_impl2<i, C, T, std::void_t<
40  decltype(internal::generalized_std_get<i>(std::declval<C&>()) = std::declval<T>())>> : std::true_type {};
41 
42  } // namespace detail
43 #endif
44 
45 
51  template<std::size_t i, typename C, typename T>
52 #ifdef __cpp_concepts
53  concept settable =
54  (not sized<C> or i < size_of_v<C>) and
55  requires(C& c, T t) { internal::generalized_std_get<i>(c) = t; };
56 #else
57  constexpr bool gettable = detail::settable_impl1<i, C, T>::value and detail::settable_impl2<i, C, T>::value;
58 #endif
59 
60 
61 } // namespace OpenKalman::collections
62 
63 #endif
Namespace for collections.
Definition: collections.hpp:27
Definition: tuple_reverse.hpp:103
Definition for collections::size_of.
Definition for collections::sized.
Definitions relating to the availability of c++ language features.