www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Null and IFTI

reply Andrew Wiley <wiley.andrew.j gmail.com> writes:
---
class Bob {
}

void doSomething(T)(Bob bob, T data) {
}

void main() {
	doSomething(null, 5); // Error: template test.doSomething(T) does not
match any function template declaration
        // Error: template test.doSomething(T) cannot deduce template
function from argument types !()(void*,int)
}
---

Bug?
Dec 10 2011
next sibling parent Peter Alexander <peter.alexander.au gmail.com> writes:
On 11/12/11 3:04 AM, Andrew Wiley wrote:
 ---
 class Bob {
 }

 void doSomething(T)(Bob bob, T data) {
 }

 void main() {
 	doSomething(null, 5); // Error: template test.doSomething(T) does not
 match any function template declaration
          // Error: template test.doSomething(T) cannot deduce template
 function from argument types !()(void*,int)
 }
 ---

 Bug?
I believe there's several bugs for this. Here's one: http://d.puremagic.com/issues/show_bug.cgi?id=2394 It is a major issue though. You get a similar thing with empty arrays (they could be empty arrays of anything!).
Dec 11 2011
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 12/11/2011 04:04 AM, Andrew Wiley wrote:
 ---
 class Bob {
 }

 void doSomething(T)(Bob bob, T data) {
 }

 void main() {
 	doSomething(null, 5); // Error: template test.doSomething(T) does not
 match any function template declaration
          // Error: template test.doSomething(T) cannot deduce template
 function from argument types !()(void*,int)
 }
 ---

 Bug?
It is very possible that it will work in 2.057, because the null literal gets an own type.
Dec 11 2011