OpenKalman
constant_value.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) 2019-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_CONSTANT_VALUE_HPP
17 #define OPENKALMAN_CONSTANT_VALUE_HPP
18 
24 
25 namespace OpenKalman
26 {
30 #ifdef __cpp_concepts
31  template<typename T> requires constant_object<T> or constant_diagonal_object<T>
32  constexpr std::convertible_to<element_type_of_t<T>> auto
33 #else
34  template<typename T, std::enable_if_t<constant_object<T> or constant_diagonal_object<T>, int> = 0>
35  constexpr auto
36 #endif
38  {
40  if constexpr (interface::get_constant_defined_for<T>)
41  return Trait::get_constant(std::forward<T>(t));
42  else if constexpr (values::fixed<element_type_of_t<T>>)
43  return element_type_of_t<T>{};
44  else
45  return internal::get_singular_component(std::forward<T>(t));
46  }
47 
48 }
49 
50 #endif
Definition for constant_object.
Definition for constant_diagonal_object.
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: object_traits.hpp:38
Definition for internal::singular_component.
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
Concepts for testing whether object_traits or library_interface definitions exist for a particular ob...
typename element_type_of< T >::type element_type_of_t
helper template for element_type_of.
Definition: element_type_of.hpp:54