mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Merge pull request #1178 from denis-sh/add-Issue-9578-workaround-to-std.algorithm.all
Add Issue 9578 workaround to `std.algorithm.all`
This commit is contained in:
commit
8dbfc1a738
1 changed files with 6 additions and 1 deletions
|
@ -9911,13 +9911,18 @@ assert(!all!"a & 1"([1, 2, 3, 5, 7, 9]));
|
||||||
bool all(alias pred, R)(R range)
|
bool all(alias pred, R)(R range)
|
||||||
if (isInputRange!R && is(typeof(unaryFun!pred(range.front))))
|
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
|
unittest
|
||||||
{
|
{
|
||||||
assert(all!"a & 1"([1, 3, 5, 7, 9]));
|
assert(all!"a & 1"([1, 3, 5, 7, 9]));
|
||||||
assert(!all!"a & 1"([1, 2, 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.
|
// Deprecated. It will be removed in January 2013. Use std.range.SortedRange.canFind.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue