mirror of
https://github.com/dlang/phobos.git
synced 2025-05-07 19:49:36 +03:00
bugzilla 4363: std.algorithm.Until is not a forward range
This commit is contained in:
parent
94855ad96c
commit
8854724323
1 changed files with 28 additions and 0 deletions
|
@ -1968,6 +1968,30 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
|
|||
_done = _input.empty || predSatisfied;
|
||||
}
|
||||
}
|
||||
|
||||
static if (!is(Sentinel == void))
|
||||
@property Until save()
|
||||
{
|
||||
Until result;
|
||||
|
||||
result._input = _input.save;
|
||||
result._sentinel = _sentinel;
|
||||
result._openRight = _openRight;
|
||||
result._done = _done;
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
@property Until save()
|
||||
{
|
||||
Until result;
|
||||
|
||||
result._input = _input.save;
|
||||
result._openRight = _openRight;
|
||||
result._done = _done;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// Ditto
|
||||
|
@ -1990,6 +2014,10 @@ until(alias pred, Range)
|
|||
unittest
|
||||
{
|
||||
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
|
||||
|
||||
assert(isForwardRange!(typeof(a.until(7))));
|
||||
assert(isForwardRange!(typeof(until!"a == 2"(a, OpenRight.no))));
|
||||
|
||||
assert(equal(a.until(7), [1, 2, 4][]));
|
||||
assert(equal(a.until(7, OpenRight.no), [1, 2, 4, 7][]));
|
||||
assert(equal(until!"a == 2"(a, OpenRight.no), [1, 2][]));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue