OpenKalman
Fixed.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) 2022-2024 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 
17 #ifndef OPENKALMAN_VALUE_CLASSES_FIXED_HPP
18 #define OPENKALMAN_VALUE_CLASSES_FIXED_HPP
19 
22 
23 namespace OpenKalman::values
24 {
31 #ifdef __cpp_concepts
32  template<values::value C, auto...constant> requires std::bool_constant<(C{constant...}, true)>::value
33 #else
34  template<typename C, auto...constant>
35 #endif
36  struct Fixed
37  {
38  static constexpr auto value {values::to_number(C {constant...})};
39 
40 
41  using value_type = std::decay_t<decltype(value)>;
42 
43 
44  using type = Fixed;
45 
46 
47  constexpr operator value_type() const { return value; }
48 
49 
50  constexpr value_type operator()() const { return value; }
51 
52 
53  constexpr Fixed() = default;
54 
55 
56 #ifdef __cpp_concepts
57  template<values::fixed T> requires (values::to_number(C {constant...}) == value)
58 #else
59  template<typename T, std::enable_if_t<(values::to_number(C {constant...}) == value), int> = 0>
60 #endif
61  explicit constexpr Fixed(const T&) {};
62 
63 
64 #ifdef __cpp_concepts
65  template<values::fixed T> requires (values::to_number(C {constant...}) == value)
66 #else
67  template<typename T, std::enable_if_t<(values::to_number(C {constant...}) == value), int> = 0>
68 #endif
69  constexpr Fixed& operator=(const T&) { return *this; }
70 
71  };
72 
73 
78 #ifdef __cpp_concepts
79  template<values::fixed T>
80 #else
81  template<typename T, std::enable_if_t<values::fixed<T>, int> = 0>
82 #endif
83  explicit Fixed(const T&) -> Fixed<std::decay_t<T>>;
84 
85 
86 } // namespace OpenKalman::values
87 
88 
89 #endif //OPENKALMAN_VALUE_CLASSES_FIXED_HPP
Definition for values::to_number.
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
constexpr auto to_number(Arg arg)
Convert any values::value to a values::number.
Definition: to_number.hpp:34
Definition for values::abs.
Definition: constant_coefficient.hpp:25
Definition: Fixed.hpp:36
Definition for ::value.