| Thread overview | |||||
|---|---|---|---|---|---|
|
April 13, 2008 Another template question | ||||
|---|---|---|---|---|
| ||||
In the documentation I read:
"If multiple templates with the same TemplateIdentifier are declared, they are distinct if they have a
different number of arguments or are differently specialized."
What happens if they are not distinct ? Is it a compiler error ?
template MyTemplate(T,U) { T a; U b;}
template MyTemplate(A,B) { A * a; B * b;}
Is this an error ?
| ||||
April 13, 2008 Re: Another template question | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Edward Diener | Edward Diener wrote:
> In the documentation I read:
>
> "If multiple templates with the same TemplateIdentifier are declared, they are distinct if they have a
> different number of arguments or are differently specialized."
>
> What happens if they are not distinct ? Is it a compiler error ?
>
> template MyTemplate(T,U) { T a; U b;}
> template MyTemplate(A,B) { A * a; B * b;}
>
> Is this an error ?
Try it.
| |||
April 13, 2008 Re: Another template question | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | Robert Fraser wrote:
> Edward Diener wrote:
>> In the documentation I read:
>>
>> "If multiple templates with the same TemplateIdentifier are declared, they are distinct if they have a
>> different number of arguments or are differently specialized."
>>
>> What happens if they are not distinct ? Is it a compiler error ?
>>
>> template MyTemplate(T,U) { T a; U b;}
>> template MyTemplate(A,B) { A * a; B * b;}
>>
>> Is this an error ?
>
> Try it.
It compiles without error. Then I tried instantiating a template instance using the template identifier and recieved an error. Makes sense. Sorry for the noise.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply