Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
math_traits.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_MATH_TRAITS_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_MATH_TRAITS_HPP_
7
8// IWYU pragma: private, include "arene/base/linalg.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11#include "arene/base/constraints/constraints.hpp"
12#include "arene/base/linalg/object_traits.hpp"
13#include "arene/base/stdlib_choice/enable_if.hpp"
14
15namespace arene {
16namespace base {
17namespace linalg {
18
19namespace math_traits_impl {
20
21/// @brief Default implementation of @c math_traits which uses member typedefs for @c mdspan and is empty for other @c T
22/// @tparam T The type whose properties are being inspected
23template <typename T, typename = arene::base::constraints<>>
24class default_math_traits {};
25
26/// @brief Default implementation of @c math_traits which uses member typedefs for @c mdspan and is empty for other @c T
27/// @tparam T The type whose properties are being inspected
28template <typename T>
29class default_math_traits<T, arene::base::constraints<std::enable_if_t<is_in_object_v<T>>>> {
30 public:
31 /// @brief The mdspan element type of @c T
32 using element_type = typename T::element_type;
33 /// @brief The mdspan value type of @c T
34 using value_type = typename T::value_type;
35 /// @brief The mdspan reference type of @c T
36 using reference = typename T::reference;
37 /// @brief The mdspan index type of @c T
38 using index_type = typename T::index_type;
39 /// @brief The mdspan size type of @c T
40 using size_type = typename T::size_type;
41 /// @brief The mdspan layout type of @c T
42 using layout_type = typename T::layout_type;
43 /// @brief The mdspan rank type of @c T
44 using rank_type = typename T::rank_type;
45 /// @brief The mdspan extents type of @c T
46 using extents_type = typename T::extents_type;
47 /// @brief The mdspan accessor type of @c T
48 using accessor_type = typename T::accessor_type;
49};
50
51} // namespace math_traits_impl
52
53/// @brief A traits struct allowing SFINAE-friendly access to the properties of types which may be linalg objects
54/// @tparam T The type whose properties are being inspected
55template <typename T>
57
58/// @brief The mdspan-equivalent element type of @c T if @c T is a linalg object, or a substitution error if not
59/// @tparam T The type to inspect
60template <class T>
61using math_element_t = typename math_traits<T>::element_type;
62
63/// @brief The mdspan-equivalent value type of @c T if @c T is a linalg object, or a substitution error if not
64/// @tparam T The type to inspect
65template <class T>
66using math_value_t = typename math_traits<T>::value_type;
67
68/// @brief The mdspan-equivalent reference type of @c T if @c T is a linalg object, or a substitution error if not
69/// @tparam T The type to inspect
70template <class T>
71using math_reference_t = typename math_traits<T>::reference;
72
73/// @brief The mdspan-equivalent index type of @c T if @c T is a linalg object, or a substitution error if not
74/// @tparam T The type to inspect
75template <class T>
76using math_index_t = typename math_traits<T>::index_type;
77
78/// @brief The mdspan-equivalent size type of @c T if @c T is a linalg object, or a substitution error if not
79/// @tparam T The type to inspect
80template <class T>
81using math_size_t = typename math_traits<T>::size_type;
82
83/// @brief The mdspan-equivalent layout type of @c T if @c T is a linalg object, or a substitution error if not
84/// @tparam T The type to inspect
85template <class T>
86using math_layout_t = typename math_traits<T>::layout_type;
87
88/// @brief The mdspan-equivalent rank type of @c T if @c T is a linalg object, or a substitution error if not
89/// @tparam T The type to inspect
90template <class T>
91using math_rank_t = typename math_traits<T>::rank_type;
92
93/// @brief The mdspan-equivalent extents type of @c T if @c T is a linalg object, or a substitution error if not
94/// @tparam T The type to inspect
95template <class T>
96using math_extents_t = typename math_traits<T>::extents_type;
97
98/// @brief The mdspan-equivalent accessor type of @c T if @c T is a linalg object, or a substitution error if not
99/// @tparam T The type to inspect
100template <class T>
101using math_accessor_t = typename math_traits<T>::accessor_type;
102
103} // namespace linalg
104} // namespace base
105} // namespace arene
106
107#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_MATH_TRAITS_HPP_
A traits struct allowing SFINAE-friendly access to the properties of types which may be linalg object...
Definition math_traits.hpp:56
Definition math_traits.hpp:17
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10