From 7db66a32eb44e5a4ebeb34ac6ed6ac72f960594c Mon Sep 17 00:00:00 2001 From: monarchdodra Date: Thu, 31 Oct 2013 19:21:52 +0100 Subject: [PATCH] make any/all predicate-able --- std/algorithm.d | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/std/algorithm.d b/std/algorithm.d index a60bfa6f5..c19c34ab3 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -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 range). Performs $(BIGOH r.length) evaluations of $(D pred). */ -bool any(alias pred, Range)(Range range) -if (is(typeof(find!pred(range)))) +template any(alias pred) { - return !find!pred(range).empty; + /// ditto + bool any(Range)(Range range) + if (is(typeof(find!pred(range)))) + { + return !find!pred(range).empty; + } } unittest @@ -10676,10 +10680,14 @@ unittest 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). */ -bool all(alias pred, R)(R range) -if (isInputRange!R && is(typeof(unaryFun!pred(range.front)))) +template all(alias pred) { - 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; + } } ///