OpenKalman
layout_of.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-2023 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_LAYOUT_OF_HPP
17 #define OPENKALMAN_LAYOUT_OF_HPP
18 
19 
20 namespace OpenKalman
21 {
22 #ifndef __cpp_lib_concepts
23  namespace detail
24  {
25  template<typename T, typename = void>
26  struct has_layout : std::false_type {};
27 
28  template<typename T>
29  struct has_layout<T, std::void_t<decltype(interface::indexible_object_traits<T>::layout)>> : std::true_type {};
30  } // namespace detail
31 #endif
32 
33 
39 #ifdef __cpp_concepts
40  template<typename T>
41 #else
42  template<typename T, typename = void>
43 #endif
44  struct layout_of : std::integral_constant<Layout, Layout::none> {};
45 
46 
47 #ifdef __cpp_concepts
48  template<typename T> requires requires { interface::indexible_object_traits<std::decay_t<T>>::layout; }
49  struct layout_of<T>
50 #else
51  template<typename T>
52  struct layout_of<T, std::enable_if_t<detail::has_layout<std::decay_t<T>>::value>>
53 #endif
54  : std::integral_constant<Layout, interface::indexible_object_traits<std::decay_t<T>>::layout> {};
55 
56 
60  template<typename T>
61  static constexpr auto layout_of_v = layout_of<T>::value;
62 
63 
64 } // namespace OpenKalman
65 
66 #endif //OPENKALMAN_LAYOUT_OF_HPP
Definition: indexible_object_traits.hpp:36
Definition: tuple_reverse.hpp:103
The root namespace for OpenKalman.
Definition: basics.hpp:34
The row dimension of a matrix, expression, or array.
Definition: layout_of.hpp:44
Definition: layout_of.hpp:26