DMD 2.027 can't implicitly instantiate templates properly based on implicit conversions via alias this. import std.stdio; struct ArrayWrapper(T) { T[] data; alias data this; } void doStuffTempl(T)(T[] data) {} void doStuffFunc(int[] data) {} void main() { ArrayWrapper!(int) foo; doStuffFunc(foo); // Works. doStuffTempl!(int)(foo); // Works. // Error: template test.doStuffTempl(T) does not match any function // template declaration // Error: template test.doStuffTempl(T) cannot deduce // template function from argument types !()(ArrayWrapper!(int)) doStuffTempl(foo); }
http://d.puremagic.com/issues/show_bug.cgi?id=2778
*** Issue 6569 has been marked as a duplicate of this issue. ***
(In reply to comment #1) > http://d.puremagic.com/issues/show_bug.cgi?id=2778 Nice reference :) Think you meant: https://github.com/D-Programming-Language/dmd/pull/472
https://github.com/D-Programming-Language/dmd/commit/35ee32cafe1cfb606e1d511807206829f8ed5855
I found a lack of my patch. Code: ---- inout(T) [n] id(T, size_t n)(inout(T) [n] v){ return v; } void main() { static struct S { ubyte[3] val = [1,2,3]; @property ref void[3] get(){ return *cast(void[3]*)&val; } alias get this; } S s; id(s); } Output: ---- test.d(18): Error: template test.id(T,uint n) does not match any function template declaration test.d(18): Error: template test.id(T,uint n) cannot deduce template function from argument types !()(S) Additional patch for repair it: https://github.com/D-Programming-Language/dmd/pull/487
https://github.com/D-Programming-Language/dmd/commit/01ba9d230205c10909a021787f00f741ee511e01