On 01/05/2012 10:14 AM, Peter Alexander wrote:
On 5/01/12 1:53 AM, Timon Gehr wrote:
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"

Strange, I could have sworn that printed 1 when I tried it the first time.

In any case, it is surely a bug. I have *explicitly* specified that T
must be int, yet it has called a version with T == float.

No it has called a version with T : float. ":" means "implicitly converts to". This is by design.

Reply via email to