On Thursday, 4 July 2013 at 20:11:56 UTC, TommiT wrote:

I have never seen any DMD code. My deduction of how DMD _must_ work is based on:
1) my understanding of how template instantiation works in C++
2) the fact that the call to foo(sa) does compile

And this is a problem, because many of such naive judgemnets are actually false.

The compiler simply must know about implicit conversion of static to dynamic arrays during template instantiation, or otherwise it wouldn't be able to do the instantiation of foo for the call to foo(sa).

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".

And not only that, the compiler must accept a non-exact match between parameter and argument types. C++ never accepts anything but an exact match between the parameter types of the instantiated template function and the types of the arguments passed in to the function at the call site which caused the instantiation. That's pretty simple logic, which is why I'm confident that I'm right even though, like I said, I don't know anything about how DMD is written.

D forums are not the right place to show confidence in C++ knowledge. What are your points regarding type deduction and implicit conversion in D?

Reply via email to