functional.forward: Fix template visibility bug

Because of the private template forwardOne, forward couldn't be used in
other modules. forwardOne cannot be a local template either since it
accepts an alias as its template parameter.
This commit is contained in:
Eugen Wissner 2018-09-21 06:23:59 +02:00
parent 180c4d3956
commit 31d4f30a49
1 changed files with 25 additions and 18 deletions

View File

@ -17,21 +17,6 @@ module tanya.functional;
import tanya.algorithm.mutation;
import tanya.meta.metafunction;
private template forwardOne(alias arg)
{
static if (__traits(isRef, arg) || __traits(isOut, arg))
{
alias forwardOne = arg;
}
else
{
@property auto forwardOne()
{
return move(arg);
}
}
}
/**
* Forwards its argument list preserving $(D_KEYWORD ref) and $(D_KEYWORD out)
* storage classes.
@ -47,13 +32,35 @@ private template forwardOne(alias arg)
*/
template forward(args...)
{
static if (args.length == 1)
static if (args.length == 0)
{
alias forward = forwardOne!(args[0]);
alias forward = AliasSeq!();
}
else static if (__traits(isRef, args[0]) || __traits(isOut, args[0]))
{
static if (args.length == 1)
{
alias forward = args[0];
}
else
{
alias forward = AliasSeq!(args[0], forward!(args[1 .. $]));
}
}
else
{
alias forward = Map!(forwardOne, args);
@property auto forwardOne()
{
return move(args[0]);
}
static if (args.length == 1)
{
alias forward = forwardOne;
}
else
{
alias forward = AliasSeq!(forwardOne, forward!(args[1 .. $]));
}
}
}