mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
make any/all predicate-able
This commit is contained in:
parent
a84a69dc8c
commit
7db66a32eb
1 changed files with 14 additions and 6 deletions
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue