Skip to content

Commit 52b6945

Browse files
authored
Merge pull request #4631 from jmh530/patch-1
[ndslice] Change pack example to something simpler
2 parents f9dd0f8 + 4fbfeb6 commit 52b6945

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

std/experimental/ndslice/selection.d

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ template pack(K...)
9696
}
9797

9898
///
99+
@safe @nogc pure nothrow unittest
100+
{
101+
import std.experimental.ndslice : sliced, Slice, pack;
102+
import std.range : iota;
103+
104+
auto r = (3 * 4 * 5 * 6).iota;
105+
auto a = r.sliced(3, 4, 5, 6);
106+
auto b = a.pack!2;
107+
108+
static immutable res1 = [3, 4];
109+
static immutable res2 = [5, 6];
110+
assert(b.shape == res1);
111+
assert(b[0, 0].shape == res2);
112+
assert(a == b);
113+
static assert(is(typeof(b) == typeof(a.pack!2)));
114+
static assert(is(typeof(b) == Slice!(2, Slice!(3, typeof(r)))));
115+
}
116+
99117
@safe @nogc pure nothrow unittest
100118
{
101119
import std.experimental.ndslice.slice;

0 commit comments

Comments
 (0)