Merge pull request #2838 from Poita/Issue13124

Fix Issue 13124 - Allow non-bool predicates for until
This commit is contained in:
Andrei Alexandrescu 2015-01-10 21:01:31 -08:00
commit e8e452862f

View file

@ -6875,9 +6875,9 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
private bool predSatisfied()
{
static if (is(Sentinel == void))
return unaryFun!pred(_input.front);
return cast(bool) unaryFun!pred(_input.front);
else
return startsWith!pred(_input, _sentinel);
return cast(bool) startsWith!pred(_input, _sentinel);
}
void popFront()
@ -6992,6 +6992,12 @@ unittest // bugzilla 13171
assert(equal(a, [0, 0, 3, 4]));
}
unittest // Issue 13124
{
auto s = "hello how\nare you";
s.until!(c => c.among!('\n', '\r'));
}
/**
Checks whether the given $(XREF2 range, isInputRange, input range) starts with
(one of) the given needle(s).