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) 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 
16 #ifndef OPENKALMAN_VALUES_FIXED_HPP
17 #define OPENKALMAN_VALUES_FIXED_HPP
18 
19 #include "basics/basics.hpp"
20 
21 namespace OpenKalman::values
22 {
23 #ifndef __cpp_concepts
24  namespace internal
25  {
26  // These functions are also used in values::to_value_type
27 
28  template<typename T, typename = void>
29  struct has_value_member : std::false_type {};
30 
31  template<typename T>
32  struct has_value_member<T, std::void_t<decltype(T::value)>> : std::true_type {};
33 
34 
35  template<typename T, typename = void>
36  struct call_result_is_defined : std::false_type {};
37 
38  template<typename T>
39  struct call_result_is_defined<T, std::void_t<decltype(std::declval<T>()())>> : std::true_type {};
40 
41 
42  template<typename T, typename = void>
43  struct call_result_is_constexpr : std::false_type {};
44 
45  template<typename T>
46  struct call_result_is_constexpr<T, std::void_t<std::bool_constant<(T{}(), true)>>> : std::true_type {};
47 
48  }
49 #endif
50 
51 
56  template<typename T>
57 #ifdef __cpp_concepts
58  concept fixed =
59  std::default_initializable<std::decay_t<T>> and
60  (requires { std::decay_t<T>::value; } or
61  requires() {
62  std::decay_t<T>{}();
63  typename std::bool_constant<(std::decay_t<T>{}(), true)>;
64  });
65 #else
66  constexpr bool fixed =
67  stdex::default_initializable<std::decay_t<T>> and
68  (internal::has_value_member<std::decay_t<T>>::value or
69  (internal::call_result_is_defined<std::decay_t<T>>::value and internal::call_result_is_constexpr<std::decay_t<T>>::value));
70 #endif
71 
72 
73 }
74 
75 #endif
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition for values::abs.
Definition: fixed-constants.hpp:23
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
Basic definitions for OpenKalman as a whole.