Instantiating template classes with default template arguments

Sean Kelly sean at f4.ca
Thu Feb 15 08:56:47 PST 2007


Bruno Medeiros wrote:
> Sean Kelly wrote:
>>
>> P.S. In writing this, I discovered that the following code compiles 
>> when it should not:
>>
>>     class C( T = int, U = int ) {}
>>     class C( T = int, U : char = int ) {}
>>
>>     void main()
>>     {
>>         auto c = new C!(int);
>>     }
> 
> What's wrong with that?

Oops... you're right.  I edited that from my original example:

     class C( T = int, U = int ) {}
     class C( T = int, U : char = char ) {}

     void main()
     {
         auto c = new C!(int);
     }

This one shouldn't compile and does.  Unless the defaults are always 
chosen from the lexically first match?



Sean



More information about the Digitalmars-d mailing list