Bug 8202 – Templated function with multiple parameters fails to compile with only one argument if type is not exact
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-06T00:58:00Z
Last change time
2015-06-09T05:15:22Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2012-06-06T00:58:39Z
This code
void func(T, R)(R range, T value)
{
}
void main()
{
ubyte[] buffer = [0, 1, 2];
buffer.func!ushort(915);
}
fails to compile, giving
q.d(8): Error: template q.func does not match any function template declaration
q.d(1): Error: template q.func(T,R) cannot deduce template function from argument types !(ushort)(ubyte[],int)
q.d(8): Error: template instance func!(ushort) errors instantiating template
If I change the function call to either
buffer.func!(ushort, ubyte[])(915);
or
buffer.func!ushort(cast(ushort)915);
then it compiles. It will also compile if you change it to
void func(R, T)(R range, T value)
{
}
void main()
{
ubyte[] buffer = [0, 1, 2];
buffer.func!(ubyte[])(915);
}
But for some reason, the compiler cannot handle having just one of the two template parameters given when the function argument associated with the given template parameter is not an exact match.
Comment #1 by k.hara.pg — 2012-06-06T04:25:11Z
*** This issue has been marked as a duplicate of issue 8129 ***