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
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>
56class math_traits : public math_traits_impl::default_math_traits<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>
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>
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>
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>
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>
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>
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>
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>
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>
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 add.hpp:20
typename math_traits< T >::element_type math_element_t
The mdspan-equivalent element type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:61
typename math_traits< T >::extents_type math_extents_t
The mdspan-equivalent extents type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:96
typename math_traits< T >::value_type math_value_t
The mdspan-equivalent value type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:66
typename math_traits< T >::size_type math_size_t
The mdspan-equivalent size type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:81
typename math_traits< T >::layout_type math_layout_t
The mdspan-equivalent layout type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:86
typename math_traits< T >::reference math_reference_t
The mdspan-equivalent reference type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:71
typename math_traits< T >::accessor_type math_accessor_t
The mdspan-equivalent accessor type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:101
typename math_traits< T >::rank_type math_rank_t
The mdspan-equivalent rank type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:91
typename math_traits< T >::index_type math_index_t
The mdspan-equivalent index type of T if T is a linalg object, or a substitution error if not.
Definition math_traits.hpp:76
Definition accumulate.hpp:37
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36