mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 13:10:35 +03:00
parent
bb0c2953dd
commit
d4dd391123
1 changed files with 11 additions and 25 deletions
|
@ -446,35 +446,21 @@ if (fun.length >= 1)
|
|||
auto map(Range)(Range r)
|
||||
if (isInputRange!(Unqual!Range))
|
||||
{
|
||||
import std.meta : AliasSeq, staticMap;
|
||||
import std.meta : staticMap;
|
||||
import std.functional : adjoin;
|
||||
|
||||
alias RE = ElementType!(Range);
|
||||
static if (fun.length > 1)
|
||||
|
||||
alias _funs = staticMap!(unaryFun, fun);
|
||||
alias _fun = adjoin!_funs;
|
||||
|
||||
// Once https://issues.dlang.org/show_bug.cgi?id=5710 is fixed
|
||||
// accross all compilers (as of 2020-04, it wasn't fixed in LDC and GDC),
|
||||
// this validation loop can be moved into a template.
|
||||
foreach (f; _funs)
|
||||
{
|
||||
import std.functional : adjoin;
|
||||
import std.meta : staticIndexOf;
|
||||
|
||||
alias _funs = staticMap!(unaryFun, fun);
|
||||
alias _fun = adjoin!_funs;
|
||||
|
||||
// Once https://issues.dlang.org/show_bug.cgi?id=5710 is fixed
|
||||
// accross all compilers (as of 2020-04, it wasn't fixed in LDC and GDC),
|
||||
// this validation loop can be moved into a template.
|
||||
foreach (f; _funs)
|
||||
{
|
||||
static assert(!is(typeof(f(RE.init)) == void),
|
||||
static assert(!is(typeof(f(RE.init)) == void),
|
||||
"Mapping function(s) must not return void: " ~ _funs.stringof);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alias _fun = unaryFun!fun;
|
||||
alias _funs = AliasSeq!(_fun);
|
||||
|
||||
// Do the validation separately for single parameters due to
|
||||
// https://issues.dlang.org/show_bug.cgi?id=15777.
|
||||
static assert(!is(typeof(_fun(RE.init)) == void),
|
||||
"Mapping function(s) must not return void: " ~ _funs.stringof);
|
||||
}
|
||||
|
||||
return MapResult!(_fun, Range)(r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue