Permalink
Browse files

Add Issue 9578 workaround to `std.algorithm.all`

As a result `all` can now be used with nested predicates.

Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=9578
  • Loading branch information...
1 parent e2692d1 commit b5ca2ef0c9742c89a587d476848e0f34df2a4f9e @denis-sh denis-sh committed Feb 27, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 std/algorithm.d
View
@@ -9838,13 +9838,18 @@ assert(!all!"a & 1"([1, 2, 3, 5, 7, 9]));
bool all(alias pred, R)(R range)
if (isInputRange!R && is(typeof(unaryFun!pred(range.front))))
{
- return find!(not!(unaryFun!pred))(range).empty;
+ // dmd @@@BUG9578@@@ workaround
+ // return find!(not!(unaryFun!pred))(range).empty;
+ bool notPred(ElementType!R a) { return !unaryFun!pred(a); }
+ return find!notPred(range).empty;
}
unittest
{
assert(all!"a & 1"([1, 3, 5, 7, 9]));
assert(!all!"a & 1"([1, 2, 3, 5, 7, 9]));
+ int x = 1;
+ assert(all!(a => a > x)([2, 3]));
}
// Deprecated. It will be removed in January 2013. Use std.range.SortedRange.canFind.

0 comments on commit b5ca2ef

Please sign in to comment.