Specialization - Major hole in the spec?
Timon Gehr
timon.gehr at gmx.ch
Wed Jan 4 17:53:45 PST 2012
On 01/05/2012 03:01 AM, Peter Alexander wrote:
> On 5/01/12 1:19 AM, Timon Gehr wrote:
>>> foo!int(0); // 1
>>
>> Matches both 1 and 2. 2 is strictly more specialized, therefore 2 is
>> chosen. Mistake on your side.
>
> It chooses 1 because I have specified T to be int so 2 can't possibly
> match.
>
Test it. int implicitly converts to float, therefore it matches 2.
void foo(T)(T t){writeln(1);}
void foo(T:float)(int t){writeln(2);}
void main(){foo!int(0);} // prints "2"
> ---
>
> As for all your other replies, thanks, it all makes more sense when you
> remove the idea that a template specialization is a specialization of
> another template.
More information about the Digitalmars-d
mailing list