Skip to content

Commit

Permalink
relax length constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Jul 31, 2016
1 parent 69c00bc commit a92618b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions std/experimental/ndslice/slice.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ auto sliced(
if (!isStaticArray!Range && !isNarrowString!Range && N)
in
{
foreach (len; lengths)
assert(len > 0,
"All lengths must be positive."
~ tailErrorMessage!());
static if (hasLength!Range)
{
static if (allowDownsize)
Expand Down Expand Up @@ -394,6 +390,28 @@ pure nothrow unittest
assert(f == iotaSlice(5, 3));
}

nothrow unittest
{
import std.experimental.ndslice.selection : iotaSlice;

auto sl = iotaSlice([0, 0], 1);

assert(sl.empty!0);
assert(sl.empty!1);

auto gcsl1 = sl.slice;
auto gcsl2 = slice!double(0, 0);

import std.experimental.allocator;
import std.experimental.allocator.mallocator;

auto tup2 = makeSlice!size_t(Mallocator.instance, sl);
auto tup1 = makeSlice!double(Mallocator.instance, 0, 0);

Mallocator.instance.dispose(tup1.array);
Mallocator.instance.dispose(tup2.array);
}

private template _Range_Types(Names...)
{
static if (Names.length)
Expand Down

0 comments on commit a92618b

Please sign in to comment.