Template Tuple Defaults

Simen Kjaeraas simen.kjaras at gmail.com
Sun Mar 30 17:04:04 PDT 2008


On Mon, 31 Mar 2008 01:29:10 +0200, Peter Neubauer  
<peterneubauer2 at gmail.com> wrote:

> Simen Kjaeraas schrieb:
>> On Sun, 30 Mar 2008 06:06:00 +0200, Peter Neubauer  
>> <peterneubauer2 at gmail.com> wrote:
>>
>>> Is there a way to give default types to template tuple parameters?
>>> Like this:
>>>
>>>
>>> class Test (TTuple ... = [char, int] )
>>> {
>>>     // ...
>>> }
>>>
>>> void main ()
>>> {
>>>     Test t; // Equivalent to Test !(char, int) t;
>>> }
>>>
>>>
>>> Obviously, that does not compile.
>>>
>>> Thanks in advance,
>>> -Peter
>>  This oughtta work (does on my confuser).
>>     import std.typetuple;
>>    class Test (TTuple ... = TypeTuple!(char, int) )
>>   {
>>     // ...
>>   }
>>    void main ()
>>   {
>>     Test t; // Equivalent to Test !(char, int) t;
>>   }
>>   -- Simen
>
> Strange, all I get is this:
>
> test.d(3): found '=' when expecting ')'
> test.d(3): { } expected following aggregate declaration
> test.d(3): no identifier for declarator TypeTuple!(char,int)
> test.d(3): semicolon expected, not ')'
> test.d(3): Declaration expected, not ')'
>
> Maybe this is a difference between D 1.0 and 2.0? (I'm using 1.0)
>
> -Peter


Tested it again. Appears I did get part of it wrong.

	class test(TTuple = TypeTuple!(char, int))

That works. Without the ellipsis. However, that is of course not what you  
wanted.
I do agree it should, though.

--Simen


More information about the Digitalmars-d-learn mailing list