@@ -27,20 +27,22 @@ struct mdspan_inspector {
2727
2828 // mdspan is trivially copyable if the value type is trivially copyable
2929 // and the layout is contiguous (which is the default)
30- static constexpr bool is_trivially_copyable =
30+ static constexpr bool is_trivially_copyable =
3131 std::is_trivially_copyable<value_type>::value &&
3232 inspector<value_type>::is_trivially_nestable &&
3333 std::is_same_v<typename MdspanType::layout_type, std::layout_right>;
3434 static constexpr bool is_trivially_nestable = false ;
3535
36- private:
36+ private:
37+ using index_type = typename extents_type::index_type;
38+
3739 // Helper to access the first element (at index 0 in all dimensions)
3840 static auto get_first_element (const type& val) {
39- std::array<typename extents_type:: index_type, ndim> indices{};
41+ std::array<index_type, ndim> indices{};
4042 return val[indices];
4143 }
4244
43- public:
45+ public:
4446 static size_t getRank (const type& val) {
4547 // Check if mdspan is empty (has zero size)
4648 if (val.size () == 0 ) {
@@ -113,8 +115,8 @@ struct mdspan_inspector {
113115 auto subsize = compute_total_size (subdims);
114116
115117 // Create index array for iteration
116- std::array<typename extents_type:: index_type, ndim> indices{};
117-
118+ std::array<index_type, ndim> indices{};
119+
118120 // Helper function to iterate through all elements
119121 auto iterate = [&](auto & self, size_t dim) -> void {
120122 if (dim == ndim) {
@@ -123,7 +125,8 @@ struct mdspan_inspector {
123125 m += subsize;
124126 } else {
125127 // Recursive case: iterate over current dimension
126- for (indices[dim] = 0 ; indices[dim] < static_cast <typename extents_type::index_type>(val.extent (dim)); ++indices[dim]) {
128+ const auto n = static_cast <index_type>(val.extent (dim));
129+ for (indices[dim] = 0 ; indices[dim] < n; ++indices[dim]) {
127130 self (self, dim + 1 );
128131 }
129132 }
@@ -146,8 +149,8 @@ struct mdspan_inspector {
146149 auto subsize = compute_total_size (subdims);
147150
148151 // Create index array for iteration
149- std::array<typename extents_type:: index_type, ndim> indices{};
150-
152+ std::array<index_type, ndim> indices{};
153+
151154 // Helper function to iterate through all elements
152155 auto iterate = [&](auto & self, size_t dim) -> void {
153156 if (dim == ndim) {
@@ -156,15 +159,15 @@ struct mdspan_inspector {
156159 vec_align += subsize;
157160 } else {
158161 // Recursive case: iterate over current dimension
159- for (indices[dim] = 0 ; indices[dim] < static_cast <typename extents_type::index_type>(dims[dim]); ++indices[dim]) {
162+ const auto n = static_cast <index_type>(dims[dim]);
163+ for (indices[dim] = 0 ; indices[dim] < n; ++indices[dim]) {
160164 self (self, dim + 1 );
161165 }
162166 }
163167 };
164168
165169 iterate(iterate, 0 );
166170 }
167-
168171};
169172
170173// Specialization for std::mdspan
@@ -183,4 +186,3 @@ struct inspector<std::mdspan<ElementType, Extents, LayoutPolicy, AccessorPolicy>
183186
184187} // namespace details
185188} // namespace HighFive
186-
0 commit comments