Variadic parameter of length 1
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 20 08:26:13 PDT 2014
On Wednesday, 20 August 2014 at 15:11:53 UTC, Dominikus Dittes
Scherkl wrote:
> I have several times seen a construct
>
> template foo(T...) if(T.length == 1)
> {
> ...
> }
>
> What is that good for?
> Why using variadic parameter if anyway exactly one parameter is
> required?!?
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
More information about the Digitalmars-d-learn
mailing list