Merge pull request #6607 from wilzbach/fix-13683

[RFC] Fix Issue 13683 - More precise error message for wrong lambda
This commit is contained in:
Nicholas Wilson 2018-11-19 15:45:02 +08:00 committed by GitHub
commit f953e2c311
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,8 +120,10 @@ template all(alias pred = "a")
Performs (at most) $(BIGOH range.length) evaluations of `pred`.
+/
bool all(Range)(Range range)
if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
if (isInputRange!Range)
{
static assert(is(typeof(unaryFun!pred(range.front))),
"`" ~ pred.stringof[1..$-1] ~ "` isn't a unary predicate function for range.front");
import std.functional : not;
return find!(not!(unaryFun!pred))(range).empty;