Bug 2972 – [tdpl] Can't overload non-templated function against template
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-05-13T09:28:00Z
Last change time
2015-06-09T01:27:59Z
Keywords
rejects-valid, TDPL
Assigned to
nobody
Creator
dsimcha
Comments
Comment #0 by dsimcha — 2009-05-13T09:28:15Z
DMD doesn't seem to allow overloading of non-templated functions against templated functions even when they have different arity and therefore no ambiguity exits. Test case:
void foo(const char[] stuff) { }
void foo(T)(const char[] stuff, const T[] moreStuff){}
C:\home\dsimcha\bin\test.d(3): Error: template test.foo(T) conflicts with function test.foo at C:\home\dsimcha\bin\test.d(1)
Comment #1 by dsimcha — 2009-05-13T09:29:48Z
Note: See bug 2268. This was fixed sometime in the last few releases, and I think the fix for it caused this bug.
Comment #2 by andrei — 2011-12-07T14:31:24Z
Breaks TDPL example, stylized below:
module main;
import std.stdio;
void overloadme(uint number)
{
writeln("This is overloadme with uint.");
}
void overloadme(long number)
{
writeln("This is overloadme with long.");
}
void overloadme(T)(T number)
{
writeln("Generic overloadme called.");
}
int main(string[] argv)
{
overloadme(25);
overloadme("Bla");
writeln("\nFinished");
readln();
return 0;
}
Comment #3 by andrej.mitrovich — 2012-01-21T18:21:01Z
*** Issue 4573 has been marked as a duplicate of this issue. ***
Comment #4 by andrej.mitrovich — 2012-01-21T18:22:11Z
*** This issue has been marked as a duplicate of issue 1528 ***