Why do std.traits use template foo(args...) instead of foo(alias arg) ?

Mathias LANG via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 18 09:20:27 PST 2014


On Thursday, 18 December 2014 at 16:10:31 UTC, Dicebot wrote:
> 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.

Thanks for the precision. Is it something that is going to be 
fixed, or is it by design ?


More information about the Digitalmars-d-learn mailing list