Variadic parameter of length 1

Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 20 08:37:09 PDT 2014


On Wed, Aug 20, 2014 at 5:34 PM, Dominikus Dittes Scherkl via
Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:
> On Wednesday, 20 August 2014 at 15:26:14 UTC, monarch_dodra wrote:
>>
>> AFAIK, it's a historical workaround to accept T as either alias or not
>> alias, as varargs have "auto alias". EG:
>>
>> foo!int //OK
>> foo!"hello" //OK too
>
>
> Ah, ok.
> And why historical? Is that not necessary anymore? What better solution is
> there today?

No better solution that I know of.

alias template parameters (alias a) match symbols (names, user-defined
types) whereas type parameter (T) match only pure types.

So when we need to match anything, we use (T...) if (T.length == 1)


More information about the Digitalmars-d-learn mailing list