Skip to content

Commit

Permalink
Merge pull request #1012 from Poita/endsWithConstraints
Browse files Browse the repository at this point in the history
Corrected constraints for std.algorithm.endsWith
  • Loading branch information
jmdavis committed Dec 16, 2012
2 parents b6b223e + b7472c4 commit ec23ff3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions std/algorithm.d
Expand Up @@ -4789,7 +4789,7 @@ assert(endsWith("abc", "x", "aaa", 'c', "sab") == 3);
*/
uint endsWith(alias pred = "a == b", Range, Ranges...)
(Range doesThisEnd, Ranges withOneOfThese)
if (isInputRange!Range && Ranges.length > 1 &&
if (isBidirectionalRange!Range && Ranges.length > 1 &&
is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[0])) : bool) &&
is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[1 .. $])) : uint))
{
Expand Down Expand Up @@ -4857,8 +4857,8 @@ if (isInputRange!Range && Ranges.length > 1 &&
/// Ditto
bool endsWith(alias pred = "a == b", R1, R2)
(R1 doesThisEnd, R2 withThis)
if (isInputRange!R1 &&
isInputRange!R2 &&
if (isBidirectionalRange!R1 &&
isBidirectionalRange!R2 &&
is(typeof(binaryFun!pred(doesThisEnd.back, withThis.back)) : bool))
{
alias doesThisEnd haystack;
Expand Down Expand Up @@ -4911,7 +4911,7 @@ if (isInputRange!R1 &&
/// Ditto
bool endsWith(alias pred = "a == b", R, E)
(R doesThisEnd, E withThis)
if (isInputRange!R &&
if (isBidirectionalRange!R &&
is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool))
{
return doesThisEnd.empty
Expand All @@ -4938,6 +4938,7 @@ unittest
@property bool empty() {return _range.empty;}
void popFront() {_range.popFront();}
void popBack() {_range.popBack();}
@property auto save() {return this;}
R _range;
}

Expand Down

0 comments on commit ec23ff3

Please sign in to comment.