Skip to content

Commit f7061b4

Browse files
jmh5309il
authored andcommitted
Add packsOf alias
1 parent 7f3d731 commit f7061b4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source/mir/ndslice/slice.d

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $(T2 sliced, Creates a slice on top of an iterator, a pointer, or an array's poi
2020
$(T2 slicedField, Creates a slice on top of a field, a random access range, or an array.)
2121
$(T2 slicedNdField, Creates a slice on top of an ndField.)
2222
$(T2 kindOf, Extracts $(LREF SliceKind).)
23+
$(T2 packsOf, Extracts dimension packs from a $(LREF Slice). Alias for $(LREF isSlice).)
2324
$(T2 isSlice, Extracts dimension packs from a type. Extracts `null` if the template argument is not a `Slice`.)
2425
$(T2 DeepElementType, Extracts the element type of a $(LREF Slice).)
2526
$(T2 Structure, A tuple of lengths and strides.)
@@ -149,6 +150,17 @@ unittest
149150
static assert(kindOf!(Slice!(Universal, [1], int*)) == Universal);
150151
}
151152

153+
/// Extracts dimension packs from a $(LREF Slice). Alias for $(LREF isSlice).
154+
alias packsOf(T) = isSlice!(T);
155+
156+
@safe pure nothrow @nogc
157+
unittest
158+
{
159+
alias S = Slice!(Universal, [2, 3], int*);
160+
161+
static assert(packsOf!S == [2, 3]);
162+
}
163+
152164
private template SkipDimension(size_t dimension, size_t index)
153165
{
154166
static if (index < dimension)

0 commit comments

Comments
 (0)