@@ -141,6 +141,14 @@ simd_index{I<:CartesianIndex{0}}(iter::CartesianRange{I}, ::CartesianIndex, I1::
141
141
CartesianIndex ((I1+ iter. start[1 ], Ilast. I... ))
142
142
end
143
143
144
+ # Split out the first N elements of a tuple
145
+ @inline split {N} (t, V:: Type{Val{N}} ) = _split ((), t, V)
146
+ @inline _split (tN, trest, V) = _split ((tN... , trest[1 ]), tail (trest), V)
147
+ # exit either when we've exhausted the input tuple or when tN has length N
148
+ @inline _split {N} (tN:: NTuple{N} , :: Tuple{} , :: Type{Val{N}} ) = tN, () # ambig.
149
+ @inline _split {N} (tN, :: Tuple{} , :: Type{Val{N}} ) = tN, ()
150
+ @inline _split {N} (tN:: NTuple{N} , trest, :: Type{Val{N}} ) = tN, trest
151
+
144
152
end # IteratorsMD
145
153
146
154
using . IteratorsMD
@@ -163,17 +171,10 @@ end
163
171
checkindex (Bool, inds, I[1 ]) & checkbounds_indices ((), tail (I))
164
172
end
165
173
@inline function checkbounds_indices {N} (inds:: Tuple , I:: Tuple{AbstractArray{CartesianIndex{N}},Vararg{Any}} )
166
- inds1, indsrest = split (inds, Val{N})
174
+ inds1, indsrest = IteratorsMD . split (inds, Val{N})
167
175
checkindex (Bool, inds1, I[1 ]) & checkbounds_indices (indsrest, tail (I))
168
176
end
169
177
170
- @inline split {N} (inds, V:: Type{Val{N}} ) = _split ((), inds, V)
171
- @inline _split (out, indsrest, V) = _split ((out... , indsrest[1 ]), tail (indsrest), V)
172
- # exit either when we've exhausted the input tuple or when it has length N
173
- @inline _split {N} (out:: NTuple{N} , :: Tuple{} , :: Type{Val{N}} ) = out, () # ambig.
174
- @inline _split {N} (out, :: Tuple{} , :: Type{Val{N}} ) = out, ()
175
- @inline _split {N} (out:: NTuple{N} , indsrest, :: Type{Val{N}} ) = out, indsrest
176
-
177
178
function checkindex {N} (:: Type{Bool} , inds:: Tuple , I:: AbstractArray{CartesianIndex{N}} )
178
179
b = true
179
180
for i in I
0 commit comments