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

Don Clugston dac at nospam.com.au
Thu Jul 19 00:08:40 PDT 2007


James Dennett wrote:
> Don Clugston wrote:
>> BCS wrote:
>>> |template Types(A...)
>>> |{
>>> |  template Values(A a)
>>> |  {
>>> |  }
>>> |}
>>> |
>>> |alias Types!(int, bool, int[]).Values!(1,true,[1,2,3]) bob;
>> 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).
> 
> Not true of C++.  Pointers to objects with external linkage
> are also allowed 

I would classify those as alias parameters, not value parameters. It's the name, 
not the value, which gets name mangled.

(even if we assume "integers" includes
> booleans and values of enumeration types).
Yes. IIRC, there's no distinction between them.

> 
> (Allowing floating point types used to be a common extension
> in C++ but was removed after experience with it.)

Yes, I think I saw it in an early version of Borland C++. But I don't see how 
you can do it properly without clearly specifying the FP ABI.


> 
> -- James


More information about the Digitalmars-d-learn mailing list