Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Decrease template instantiation in std.algorithm.searching : all & any" #6988

Merged
merged 1 commit into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions std/algorithm/searching.d
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ template all(alias pred = "a")
{
static assert(is(typeof(unaryFun!pred(range.front))),
"`" ~ pred.stringof[1..$-1] ~ "` isn't a unary predicate function for range.front");
foreach (ref e; range)
if (!unaryFun!pred(e))
return false;
return true;
import std.functional : not;

return find!(not!(unaryFun!pred))(range).empty;
}
}

Expand All @@ -154,6 +153,7 @@ are true.
{
int x = 1;
assert(all!(a => a > x)([2, 3]));
assert(all!"a == 0x00c9"("\xc3\x89")); // Test that `all` auto-decodes.
}

/++
Expand All @@ -172,10 +172,7 @@ template any(alias pred = "a")
bool any(Range)(Range range)
if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
{
foreach (ref e; range)
if (unaryFun!pred(e))
return true;
return false;
return !find!pred(range).empty;
}
}

Expand Down Expand Up @@ -211,6 +208,7 @@ evaluate to true.
{
auto a = [ 1, 2, 0, 4 ];
assert(any!"a == 2"(a));
assert(any!"a == 0x3000"("\xe3\x80\x80")); // Test that `any` auto-decodes.
}

// balancedParens
Expand Down