mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 07:30:33 +03:00
Fix issue 11576.
This commit is contained in:
parent
dc4bd532d0
commit
c1ce350db9
1 changed files with 19 additions and 2 deletions
|
@ -8139,8 +8139,17 @@ if (s != SwapStrategy.stable
|
||||||
if (blackouts[right].pos + blackouts[right].len >= range.length)
|
if (blackouts[right].pos + blackouts[right].len >= range.length)
|
||||||
{
|
{
|
||||||
range.popBackN(blackouts[right].len);
|
range.popBackN(blackouts[right].len);
|
||||||
--right;
|
|
||||||
continue;
|
// Since right is unsigned, we must check for this case, otherwise
|
||||||
|
// we might turn it into size_t.max and the loop condition will not
|
||||||
|
// fail when it should.
|
||||||
|
if (right > 0)
|
||||||
|
{
|
||||||
|
--right;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// Advance to next blackout on the left
|
// Advance to next blackout on the left
|
||||||
assert(blackouts[left].pos >= steps);
|
assert(blackouts[left].pos >= steps);
|
||||||
|
@ -8266,6 +8275,14 @@ unittest
|
||||||
== [0, 9, 8, 7, 4, 5]);
|
== [0, 9, 8, 7, 4, 5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
// Issue 11576
|
||||||
|
auto arr = [1,2,3];
|
||||||
|
arr = arr.remove!(SwapStrategy.unstable)(2);
|
||||||
|
assert(arr == [1,2]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reduces the length of the bidirectional range $(D range) by removing
|
Reduces the length of the bidirectional range $(D range) by removing
|
||||||
elements that satisfy $(D pred). If $(D s = SwapStrategy.unstable),
|
elements that satisfy $(D pred). If $(D s = SwapStrategy.unstable),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue