Variadic function with parameters all of a specific type

Timon Gehr via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 17 14:20:01 PDT 2016


On 17.06.2016 23:00, Nordlöw wrote:
> I want to create a function that takes a variadic number of arguments
> all of a specific type, say T, without having to create GC-allocated
> heap array.
>
> Is there a better way than:
>
> f(Args...)(Args args)
>      if (allSameType!(Args, T);
>
> in terms of template bloat?

alias T=int;

void foo(T[] a...)@nogc{}

void bar()@nogc{
     foo(1,2,3);
}



More information about the Digitalmars-d-learn mailing list