On Friday, 15 July 2016 at 04:08:19 UTC, Basile B. wrote:

With D style variadics it works, you can build the array from the list and have a static array:

=====
void foo(T...)(T t)
{
    T[0][T.length] tt = [t]; // T[0] is the type
    writeln(tt); // [1,2,3]
    static assert(isStaticArray!(typeof(tt)));
}

void main(string[] args)
{
    foo(1,2,3);
}
=====

Note that you should check that the elements of T[] have all the same type.
It shouldn't be a big problem.

Thanks, that way of doing it does work. I guess that means there's no easy way to make sure all T are the same type without a template constraint? It's not that hard, you're right, but it's less elegant I think.

Just a shame that

auto makeStruct(long[] nums...)();

doesn't work; it seems like it would have.

Oh well, we can't have everything.
Thanks for the help though!

Reply via email to