www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1263] New: Template function overload fails when overloading on both template and non-template class

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1263

           Summary: Template function overload fails when overloading on
                    both template and non-template class
           Product: D
           Version: 1.015
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dhaffey gmail.com


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.


-- 
Jun 10 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1263






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
}


-- 
Jun 10 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1263


onlystupidspamhere yahoo.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed in 1.017.


-- 
Jun 26 2007