9 #ifndef EAGINE_VEC_MAT_TRAITS_HPP
10 #define EAGINE_VEC_MAT_TRAITS_HPP
15 #include <type_traits>
20 struct is_known_vector_type : std::false_type {};
23 constexpr
const bool is_known_vector_type_v = is_known_vector_type<T>::value;
25 template <
typename T, span_
size_t N>
26 struct is_known_vector_type<T[N]> : std::is_scalar<T> {};
29 struct is_known_matrix_type : std::false_type {};
32 constexpr
const bool is_known_matrix_type_v = is_known_matrix_type<T>::value;
34 template <
typename T, span_
size_t C, span_
size_t R>
35 struct is_known_matrix_type<T[C][R]> : std::is_scalar<T> {};
38 struct canonical_compound_type : nothing_t {};
41 using canonical_compound_type_t =
typename canonical_compound_type<T>::type;
43 template <
typename C,
typename CT>
44 struct has_canonical_type : std::is_same<canonical_compound_type_t<C>, CT> {};
46 template <
typename T, span_
size_t N>
47 struct canonical_compound_type<T[N]> : type_identity<std::remove_cv_t<T[N]>> {};
49 template <
typename T, span_
size_t C, span_
size_t R>
50 struct canonical_compound_type<T[C][R]>
51 : type_identity<std::remove_cv_t<T[C][R]>> {};
54 struct compound_element_type : type_identity<std::remove_cv_t<T>> {};
56 template <
typename T, span_
size_t N>
57 struct compound_element_type<T[N]> : type_identity<std::remove_cv_t<T>> {};
59 template <
typename T, span_
size_t C, span_
size_t R>
60 struct compound_element_type<T[C][R]> : type_identity<std::remove_cv_t<T>> {};
63 struct canonical_element_type
64 : compound_element_type<canonical_compound_type_t<T>> {};
67 using canonical_element_type_t =
typename canonical_element_type<T>::type;
70 struct compound_view_maker;
73 static inline auto element_view(
const C& c) noexcept {
74 return compound_view_maker<C>()(c);
77 template <
typename T, span_
size_t N>
78 struct compound_view_maker<T[N]> {
79 auto operator()(T (&v)[N])
const noexcept -> span<T> {
80 return {
static_cast<T*
>(v), N};
84 template <
typename T, span_
size_t N>
85 static inline auto element_view(T (&v)[N]) noexcept {
86 return compound_view_maker<T[N]>()(v);
89 template <
typename T, span_
size_t C, span_
size_t R>
90 struct compound_view_maker<T[C][R]> {
91 auto operator()(T (&v)[C][R])
const noexcept -> span<T> {
96 template <
typename T, span_
size_t C, span_
size_t R>
97 static inline auto element_view(T (&m)[C][R]) noexcept {
98 return compound_view_maker<T[C][R]>()(m);
101 template <
typename C>
102 struct is_row_major : std::false_type {};
106 #endif // EAGINE_VEC_MAT_TRAITS_HPP