Why do std.traits use template foo(args...) instead of foo(alias arg) ?
Dicebot via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Dec 18 08:10:30 PST 2014
On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote:
> An exemple being fullyQualifiedName:
> https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L415
>
> I don't get this pattern. Is it documented somewhere ?
Full pattern looks like this:
template foo(T...)
if (T.length == 1)
This is a way to workaround D template argument limitation - you
can't have any parameter that accepts both types and symbols
(`alias T` and `T` at once) other than variadic parameter. Limit
variadic length to 1 and you emulate such "accepts anything"
parameter.
More information about the Digitalmars-d-learn
mailing list