2
2
#define LIBIM_TRAITS_H
3
3
#include < libim/types/flags.h>
4
4
#include < libim/types/typemask.h>
5
+ #include < libim/math/abstract_vector.h>
6
+
7
+ #include < array>
5
8
#include < type_traits>
6
9
7
10
namespace libim ::utils {
@@ -48,11 +51,36 @@ namespace libim::utils {
48
51
template <typename T>
49
52
struct is_flags <Flags<T>> : std::true_type {};
50
53
54
+ template <typename >
55
+ struct is_std_array : std::false_type {};
56
+
57
+ template <typename T, std::size_t N>
58
+ struct is_std_array <std::array<T, N>> : std::true_type {};
59
+
60
+ template <typename >
61
+ struct is_numeric_std_array : std::false_type {};
62
+
63
+ template <typename T, std::size_t N>
64
+ struct is_numeric_std_array <std::array<T, N>> : std::is_arithmetic<T> {};
65
+
51
66
template <typename >
52
67
struct is_typemask : std::false_type {};
53
68
54
69
template <typename T>
55
70
struct is_typemask <TypeMask<T>> : std::true_type {};
71
+
72
+ template <typename >
73
+ struct array_size ;
74
+
75
+ template <typename T, size_t N>
76
+ struct array_size <std::array<T,N>> {
77
+ static constexpr size_t size = N;
78
+ };
79
+
80
+ template <typename T, size_t N>
81
+ struct array_size <T[N]> {
82
+ static size_t const size = N;
83
+ };
56
84
}
57
85
58
86
@@ -67,7 +95,7 @@ namespace libim::utils {
67
95
typename Container::value_type
68
96
>;
69
97
70
- // Triats
98
+ /* Triats */
71
99
72
100
// Does C have member function 'capacity'
73
101
template <typename C>
@@ -85,16 +113,28 @@ namespace libim::utils {
85
113
template <typename C>
86
114
constexpr bool has_mf_reserve = detail::has_reserve<C>::value;
87
115
116
+ // Is T of type std::array<T,N>
117
+ template <typename T>
118
+ constexpr bool isStdArray = detail::is_std_array<T>::value;
119
+
120
+ // Is T numeric std::array<T, N> type
121
+ template <typename T>
122
+ constexpr bool isNumericStdArray = detail::is_numeric_std_array<T>::value;
123
+
88
124
// Is T of type Flags
89
125
template <typename T>
90
- constexpr bool is_flags = detail::is_flags<T>::value;
126
+ constexpr bool isFlags = detail::is_flags<T>::value;
91
127
92
128
// Is T of type TypeMask
93
129
template <typename T>
94
- constexpr bool is_typemask = detail::is_typemask<T>::value;
130
+ constexpr bool isTypeMask = detail::is_typemask<T>::value;
95
131
96
132
// is T of type enum or Flags or TypeMask
97
133
template <typename T>
98
- constexpr bool is_enum = std::is_enum_v<T> || is_flags<T> || is_typemask<T>;
134
+ constexpr bool isEnum = std::is_enum_v<T> || isFlags<T> || isTypeMask<T>;
135
+
136
+ /* Utility type triats */
137
+ template <typename T>
138
+ constexpr std::size_t arraySize = detail::array_size<T>::size;
99
139
}
100
140
#endif // LIBIM_TRAITS_H
0 commit comments