Skip to content

Commit

Permalink
Merge pull request #4631 from jmh530/patch-1
Browse files Browse the repository at this point in the history
[ndslice] Change pack example to something simpler
  • Loading branch information
9il authored Jul 27, 2016
2 parents f9dd0f8 + 4fbfeb6 commit 52b6945
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions std/experimental/ndslice/selection.d
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ template pack(K...)
}

///
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice : sliced, Slice, pack;
import std.range : iota;

auto r = (3 * 4 * 5 * 6).iota;
auto a = r.sliced(3, 4, 5, 6);
auto b = a.pack!2;

static immutable res1 = [3, 4];
static immutable res2 = [5, 6];
assert(b.shape == res1);
assert(b[0, 0].shape == res2);
assert(a == b);
static assert(is(typeof(b) == typeof(a.pack!2)));
static assert(is(typeof(b) == Slice!(2, Slice!(3, typeof(r)))));
}

@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
Expand Down

0 comments on commit 52b6945

Please sign in to comment.