Skip to content

Commit 9bee18f

Browse files
committed
wrapper for slicedExactly
1 parent e0c3ff9 commit 9bee18f

1 file changed

Lines changed: 2 additions & 22 deletions

File tree

‎source/mir/ndslice/slice.d‎

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -311,31 +311,11 @@ auto slicedExactly(size_t N, Iterator)(return scope Iterator iterator, size_t[N]
311311
if (!__traits(isStaticArray, Iterator) && N
312312
&& !is(Iterator : Slice!(_Iterator, _N, kind), _Iterator, size_t _N, SliceKind kind))
313313
{
314-
alias C = ImplicitlyUnqual!(typeof(iterator));
315-
size_t[N] _lengths;
316-
foreach (i; Iota!N)
317-
_lengths[i] = lengths[i];
318-
ptrdiff_t[1] _strides = 0;
319314
static if (isDynamicArray!Iterator)
320315
{
321-
assert(lengthsProduct(_lengths) == iterator.length,
322-
"array length should be exactly equal to the product of constructed ndslice lengths");
323-
auto ptr = iterator.length ? &iterator[0] : null;
324-
return Slice!(typeof(C.init[0])*, N)(_lengths, ptr);
325-
}
326-
else
327-
{
328-
// break safety
329-
if (false)
330-
{
331-
++iterator;
332-
--iterator;
333-
iterator += 34;
334-
iterator -= 34;
335-
}
336-
import core.lifetime: move;
337-
return Slice!(C, N)(_lengths, iterator.move);
316+
assert(lengthsProduct(lengths) == iterator.length, "array length should be exactly equal to the product of constructed ndslice dimensions");
338317
}
318+
return iterator.sliced(lengths);
339319
}
340320

341321
/// Test case for Issue 313 https://github.com/libmir/mir-algorithm/issues/313

0 commit comments

Comments
 (0)