OpenKalman
to_value_type.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-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_VALUES_TO_VALUE_TYPE_HPP
17 #define OPENKALMAN_VALUES_TO_VALUE_TYPE_HPP
18 
20 
21 namespace OpenKalman::values
22 {
26  template<typename Arg>
27  constexpr decltype(auto)
28  to_value_type(Arg&& arg)
29  {
30 #ifdef __cpp_concepts
31  if constexpr (requires { std::decay_t<Arg>::value; })
33  else if constexpr (requires { std::forward<Arg>(arg)(); })
34  return std::forward<Arg>(arg)();
35  else
36  return std::forward<Arg>(arg);
37 #else
38  if constexpr (internal::has_value_member<std::decay_t<Arg>>::value)
40  else if constexpr (internal::call_result_is_defined<std::decay_t<Arg>>::value)
41  return std::forward<Arg>(arg)();
42  else
43  return std::forward<Arg>(arg);
44 #endif
45  }
46 
47 }
48 
49 #endif
decltype(auto) constexpr to_value_type(Arg &&arg)
Convert, if necessary, a fixed or dynamic value to its underlying base type.
Definition: to_value_type.hpp:28
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
Definition for ::fixed.