Why can't templates use tuples for for argument types?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Jul 17 13:50:09 PDT 2007


"BCS" <ao at pathlink.com> wrote in message 
news:ce0a3343bf108c99670e3f3ff2c at news.digitalmars.com...
>
> A few times, I have wanted a template that works just like a tuple taking 
> template but where one or more of the spots must be filled and a keep 
> separate from the rest.
>
> template Foo(A, B...) {}
>
> these should work
>
> Foo!(1, int);
> Foo!(int, 1);
> Foo!(Foo!(int, 1));
>
> this shouldn't
>
> Foo!();

template Foo(A...)
{
    static assert(A.length >= 1, "Foo needs at least one parameter");

    do something with A[0];
    do something else with A[1 .. $];
} 




More information about the Digitalmars-d-learn mailing list