Skip to content

Commit

Permalink
Merge pull request #4976 from ErinaceusEuropaeus/fix_zip_save
Browse files Browse the repository at this point in the history
Fix std.range.Zip.save
  • Loading branch information
JackStouffer committed Dec 21, 2016
2 parents 64ed49b + 3daef3f commit ab84f30
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion std/range/package.d
Expand Up @@ -3903,7 +3903,7 @@ struct Zip(Ranges...)
@property Zip save()
{
//Zip(ranges[0].save, ranges[1].save, ..., stoppingPolicy)
return mixin (q{Zip(%(ranges[%s]%|, %), stoppingPolicy)}.format(iota(0, R.length)));
return mixin (q{Zip(%(ranges[%s].save%|, %), stoppingPolicy)}.format(iota(0, R.length)));
}
}

Expand Down Expand Up @@ -4423,6 +4423,19 @@ pure unittest
auto zz = z.save;
}

pure unittest
{
import std.typecons : tuple;

auto r1 = [0,1,2];
auto r2 = [1,2,3];
auto z1 = zip(refRange(&r1), refRange(&r2));
auto z2 = z1.save;
z1.popFront();
assert(z1.front == tuple(1,2));
assert(z2.front == tuple(0,1));
}

/*
Generate lockstep's opApply function as a mixin string.
If withIndex is true prepend a size_t index to the delegate.
Expand Down

0 comments on commit ab84f30

Please sign in to comment.