diff options
| author | Eugen Wissner <belka@caraus.de> | 2018-09-21 06:23:59 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2018-09-21 06:23:59 +0200 |
| commit | 31d4f30a4965a0806317909bd84beabbd7bc327c (patch) | |
| tree | ae34f42afabaf6effde4e807a2095e540c294eb8 | |
| parent | 180c4d3956bf4004299f1fa759513b7c39fc9158 (diff) | |
| download | tanya-31d4f30a4965a0806317909bd84beabbd7bc327c.tar.gz | |
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.
| -rw-r--r-- | source/tanya/functional.d | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/source/tanya/functional.d b/source/tanya/functional.d index 3b5adf5..f628a51 100644 --- a/source/tanya/functional.d +++ b/source/tanya/functional.d @@ -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 = AliasSeq!(); + } + else static if (__traits(isRef, args[0]) || __traits(isOut, args[0])) { - alias forward = forwardOne!(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 .. $])); + } } } |
