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 "values/values.hpp"
21 
23 {
24 #ifndef __cpp_concepts
25  namespace detail
26  {
27  template<std::size_t i, typename C, typename T, typename = void>
28  struct settable_impl : std::false_type {};
29 
30  template<std::size_t i, typename C, typename T>
31  struct settable_impl<i, C, T,
32  std::void_t<decltype(collections::get<i>(std::declval<C&>()) = std::declval<T>())>> : std::true_type {};
33  }
34 #endif
35 
36 
42  template<std::size_t i, typename C, typename T>
43 #ifdef __cpp_concepts
44  concept settable = requires(C& c, T t) { collections::get<i>(c) = t; };
45 #else
46  constexpr bool settable = detail::settable_impl<i, C, T>::value;
47 #endif
48 
49 
50 }
51 
52 #endif
Namespace for collections.
Definition: collections.hpp:27
Definition for collections::get.
Header file for code relating to values (e.g., scalars and indices)
constexpr bool settable
C has an element i that can be set by assigning the result of a get(...) function to an object of typ...
Definition: settable.hpp:46