OpenKalman
scalar_type_of_deprecated.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_DESCRIPTORS_SCALAR_TYPE_OF_HPP
17 #define OPENKALMAN_DESCRIPTORS_SCALAR_TYPE_OF_HPP
18 
19 #include <type_traits>
20 #include "linear-algebra/coordinates/interfaces/coordinate_descriptor_traits.hpp"
24 
26 {
32 #ifdef __cpp_concepts
33  template<pattern T>
34 #else
35  template<typename T, typename = void, typename = void>
36 #endif
37  struct scalar_type_of { using type = double; };
38 
39 
43  template<typename T>
44  using scalar_type_of_t = typename scalar_type_of<T>::type;
45 
46 
47 #ifdef __cpp_concepts
48  template<descriptor T> requires
49  requires { typename interface::coordinate_descriptor_traits<std::decay_t<T>>::scalar_type; }
50  struct scalar_type_of<T>
51 #else
52  template<typename T>
53  struct scalar_type_of<T, std::enable_if_t<descriptor<T>>,
54  std::void_t<typename interface::coordinate_descriptor_traits<std::decay_t<T>>::scalar_type>>
55 #endif
56  {
57  using type = typename interface::coordinate_descriptor_traits<std::decay_t<T>>::scalar_type;
58  };
59 
60 
61 #ifdef __cpp_concepts
62  template<descriptor_range T> requires
63  requires { typename interface::coordinate_set_traits<std::decay_t<T>>::scalar_type; }
64  struct scalar_type_of<T>
65 #else
66  template<typename T>
67  struct scalar_type_of<T, std::enable_if_t<descriptor_range<T>>,
68  std::void_t<typename interface::coordinate_set_traits<std::decay_t<T>>::scalar_type>>
69 #endif
70  {
71  using type = typename interface::coordinate_set_traits<std::decay_t<T>>::scalar_type;
72  };
73 
74 
75 #ifdef __cpp_concepts
76  template<descriptor_tuple T> requires (not descriptor_range<T>) and
77  requires { typename interface::coordinate_set_traits<std::decay_t<T>>::scalar_type; }
78  struct scalar_type_of<T>
79 #else
80  template<typename T>
81  struct scalar_type_of<T, std::enable_if_t<descriptor_tuple<T>>,
82  std::void_t<typename interface::coordinate_set_traits<std::decay_t<T>>::scalar_type>>
83 #endif
84  {
85  using type = typename interface::coordinate_set_traits<std::decay_t<T>>::scalar_type;
86  };
87 
88 
89 } // namespace OpenKalman::coordinates
90 
91 #endif //OPENKALMAN_DESCRIPTORS_SCALAR_TYPE_OF_HPP
Definition: tuple_reverse.hpp:103
Definition for coordinates::pattern.
Definition for coordinates::descriptor.
Definition: compares_with.hpp:28
Definition for pattern_range.
Traits for coordinates::pattern objects.
Definition: coordinate_descriptor_traits.hpp:41
The scalar type, if any, associated with a coordinates::pattern.
Definition: scalar_type_of_deprecated.hpp:37
typename scalar_type_of< T >::type scalar_type_of_t
Helper template for scalar_type_of.
Definition: scalar_type_of_deprecated.hpp:44