make any/all predicate-able

This commit is contained in:
monarchdodra 2013-10-31 19:21:52 +01:00
parent a84a69dc8c
commit 7db66a32eb

View file

@ -10658,10 +10658,14 @@ Returns $(D true) if and only if a value $(D v) satisfying the
predicate $(D pred) can be found in the forward range $(D predicate $(D pred) can be found in the forward range $(D
range). Performs $(BIGOH r.length) evaluations of $(D pred). range). Performs $(BIGOH r.length) evaluations of $(D pred).
*/ */
bool any(alias pred, Range)(Range range) template any(alias pred)
if (is(typeof(find!pred(range))))
{ {
return !find!pred(range).empty; /// ditto
bool any(Range)(Range range)
if (is(typeof(find!pred(range))))
{
return !find!pred(range).empty;
}
} }
unittest unittest
@ -10676,10 +10680,14 @@ unittest
Returns $(D true) if and only if all values in $(D range) satisfy the Returns $(D true) if and only if all values in $(D range) satisfy the
predicate $(D pred). Performs $(BIGOH r.length) evaluations of $(D pred). predicate $(D pred). Performs $(BIGOH r.length) evaluations of $(D pred).
*/ */
bool all(alias pred, R)(R range) template all(alias pred)
if (isInputRange!R && is(typeof(unaryFun!pred(range.front))))
{ {
return find!(not!(unaryFun!pred))(range).empty; /// ditto
bool all(R)(R range)
if (isInputRange!R && is(typeof(unaryFun!pred(range.front))))
{
return find!(not!(unaryFun!pred))(range).empty;
}
} }
/// ///