OpenKalman
mdspan-object.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_INTERFACES_MDSPAN_OBJECT_TRAITS_HPP
17 #define OPENKALMAN_INTERFACES_MDSPAN_OBJECT_TRAITS_HPP
18 
19 #include "basics/basics.hpp"
22 
23 namespace OpenKalman::interface
24 {
29  template<typename T, typename Extents, typename LayoutPolicy, typename AccessorPolicy>
30  struct object_traits<stdex::mdspan<T, Extents, LayoutPolicy, AccessorPolicy>>
31  {
32  static const bool is_specialized = true;
33 
34  // An identity function for get_mdspan is not necessary because it will never be called.
35 
36 
40  static constexpr auto
41 #ifdef __cpp_concepts
42  get_constant = [](const auto& m) requires std::same_as<AccessorPolicy, internal::accessor_constant<T>>
43 #else
44  get_constant = [](const auto& m,
45  std::enable_if_t<stdex::same_as<typename std::decay_t<decltype(m)>::accessor_type, internal::accessor_constant<T>>, int> = 0)
46 #endif
47  {
48  return *(m.accessor().data_handle());
49  };
50 
51  };
52 
53 }
54 
55 
56 #endif
Definition: basics.hpp:41
static const bool is_specialized
Identifies types for which object_traits is specialized.
Definition: object_traits.hpp:44
Forward declaration of object_traits, which must be defined for all objects used in OpenKalman...
Definition: constant_mdspan_policies.hpp:91
Definition: object_traits.hpp:38
Basic definitions for OpenKalman as a whole.