Function parameters from TypeTuple

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 17 10:55:14 PDT 2014


On 10/17/2014 10:44 AM, Tofu Ninja wrote:
> Basicly what I am trying to do is have a function template that will
> generate its parameters to be arrays of the types of a type tuple.
>
> So for instance the parameters of f!(int, char) would be (int[], char[])...
>
> No matter what I try, the compiler vomits all over me...

Perhaps string does not match cha[]? I made the elements const in the 
following code but you don't need them if you don't need to pass string:

void f(A, B)(const(A)[] as, const(B)[] bs)
{}

void main()
{
     f!(int, char)([42], "s");

     // And you don't need to specify the template parameters yourself:
     f([42], "s");
}

Ali



More information about the Digitalmars-d-learn mailing list