From 6219fcaaa81d97cfc2ffc02f4c09c6597b4c8f6e Mon Sep 17 00:00:00 2001 From: Peter Alexander Date: Fri, 2 Jan 2015 21:34:22 +0000 Subject: [PATCH] Fix Issue 13124 - Allow non-bool predicates for until https://issues.dlang.org/show_bug.cgi?id=13124 --- std/algorithm.d | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/std/algorithm.d b/std/algorithm.d index 7bc187d5c..d165d156b 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -6626,9 +6626,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() @@ -6726,6 +6726,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')); +} + /** If the range $(D doesThisStart) starts with $(I any) of the $(D withOneOfThese) ranges or elements, returns 1 if it starts with $(D