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

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Mon Jul 16 12:46:11 PDT 2007


BCS wrote:

> |template Types(A...)
> |{
> |  template Values(A a)
> |  {
> |  }
> |}
> |
> |alias Types!(int, bool, int[]).Values!(1,true,[1,2,3]) bob;

Probably because the compiler does not unfold the tuple. I've filed a bug
about instantiating an array literal from a tuple. It has a similar
problem:

alias Tuple!(1,2,3) a;

int[] foo = [ a ];  // does not work, but
int[] foo = [ a[0], a[1], a[2] ]; // does

Here you can also do

> |template Types(A...)
> |{
> |  template Values(A[0] a, A[1] b, A[2] c)
> |  {
> |  }
> |}
> |
> |alias Types!(int, bool, int[]).Values!(1,true,[1,2,3]) bob;


More information about the Digitalmars-d-learn mailing list