mirror of
https://github.com/dlang/phobos.git
synced 2025-05-14 08:55:54 +03:00
Merge pull request #2522 from sinkuu/fix_tee
std.range.tee should accept function symbols
This commit is contained in:
commit
db0fa5e7d5
1 changed files with 16 additions and 2 deletions
18
std/range.d
18
std/range.d
|
@ -10105,12 +10105,17 @@ if (is(typeof(fun) == void) || isSomeFunction!fun)
|
|||
it with the type of $(D inputRange.front).
|
||||
*/
|
||||
static if (is(typeof(fun) == void))
|
||||
alias _fun = fun!(typeof(inputRange.front));
|
||||
else
|
||||
alias _fun = fun;
|
||||
|
||||
static if (isFunctionPointer!_fun || isDelegate!_fun)
|
||||
{
|
||||
return tee!pipeOnPop(inputRange, fun!(typeof(inputRange.front)));
|
||||
return tee!pipeOnPop(inputRange, _fun);
|
||||
}
|
||||
else
|
||||
{
|
||||
return tee!pipeOnPop(inputRange, fun);
|
||||
return tee!pipeOnPop(inputRange, &_fun);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10265,3 +10270,12 @@ unittest
|
|||
assert(equal(txt, appResult) && equal(appResult, appSink.data));
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
// Issue 13483
|
||||
static void func1(T)(T x) {}
|
||||
void func2(int x) {}
|
||||
|
||||
auto r = [1, 2, 3, 4].tee!func1.tee!func2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue