Function templates do implicit conversions for their arguments

Maxim Fomin maxim at maxim-fomin.ru
Thu Jul 4 19:45:45 PDT 2013


On Thursday, 4 July 2013 at 21:31:43 UTC, TommiT wrote:
> On Thursday, 4 July 2013 at 20:43:45 UTC, Maxim Fomin wrote:
>>
>> Implementation may do other way, at first instantiate template 
>> (with deduced type) and then try to plug arguments as in case 
>> of non-template function (including implicit conversion). If 
>> it cannot, implementation issues error message for a 
>> particular problem and then general "template error 
>> instantiation".
>
> Well, it doesn't really matter how it is implemented. What 
> matters is that the implicit conversion does happen.

Issue in this case is not that it happens per se (of course, it 
does), but whether implicit conversion influences type deduction. 
As it was mentioned previously about particular example, it does 
not.

>
>> What are your points regarding type deduction and implicit 
>> conversion in D?
>
> I thought my point would have been made painstakingly clear by 
> now. My point is that D behaves in a way that's very different 
> from C++ or any other language which does heterogeneous 
> translation of type parameters. And I've never seen any mention 
> of this neither in the spec nor in TDPL (nor have I seen this 
> discussed before). This difference should be mentioned 
> somewhere newcomers are guaranteed to see it.

Please provide evidence which support your point about D. 
Previous example doesn't do that. Piece of dmd implementation is 
appreciated. Otherwise claims about what implementation does are 
of little value.


More information about the Digitalmars-d mailing list