Null and IFTI

deadalnix deadalnix at gmail.com
Sun Dec 11 09:54:34 PST 2011


Le 11/12/2011 13:05, kenji hara a écrit :
> 2.057 will compile this code, because it adds the new feature.
> Now null literal has the type that is expressed as typeof(null), not void*.
> And typeof(null) is derived from all class types.
>
> static assert(is(typeof(null) : Bob));   // pass in 2.057
>
> Then IFTI works with null literal correctly.
>
> Kenji Hara
>
> 2011/12/11 Andrew Wiley<wiley.andrew.j at gmail.com>:
>> ---
>> 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?

Nice ! This will help generic programming a lot.


More information about the Digitalmars-d mailing list