Bug 1263 – Template function overload fails when overloading on both template and non-template class
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-06-10T18:21:00Z
Last change time
2014-02-16T15:24:22Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
dhaffey
Comments
Comment #0 by dhaffey — 2007-06-10T18:21:20Z
struct A {}
class B() {}
class C {}
void foo()(int) {}
void foo()(A) {}
void foo()(B!()) {}
//void foo()(C) {}
void main()
{
foo(5); // ok
foo(A()); // ok
foo(new B!()); // error if C overload available
//foo(new C); // ok (with C overload available)
}
Uncommenting the C overload declaration produces this error:
template t.foo() foo() matches more than one function template declaration, foo() and foo()
This is apparently only triggered by the call to the B overload.
Comment #1 by dhaffey — 2007-06-10T19:21:51Z
It appears to behave similarly with aliased template instantiations:
class B() {}
class C() {}
alias C!() D;
void foo()(B!()) {}
void foo()(C!()) {}
//void foo()(D) {}
void main()
{
foo(new B!()); // error if D overload is used instead of C
}
Comment #2 by onlystupidspamhere — 2007-06-26T14:25:14Z