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

BCS ao at pathlink.com
Tue Jul 17 10:03:42 PDT 2007


Reply to Don,

> int [] is not an allowed as a template value parameter. Only char[],
> wchar[], dchar[], integers, and floating-point types can be template
> value parameters. (In C++, only integers are allowed).
> 


strange, this works

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

And while I'm thinking about it; why isn't there something like a "one space 
tuple"?

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!();


(alias dosen't work)




More information about the Digitalmars-d-learn mailing list