www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3472] New: alias of a template cannot be used to override a function required by an interface

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

           Summary: alias of a template cannot be used to override a
                    function required by an interface
           Product: D
           Version: 1.048
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: fawzi gmx.ch


--- Comment #0 from Fawzi Mohamed <fawzi gmx.ch> 2009-11-04 08:00:32 PST ---
The following shows that alias cannot be used to override a function that is
requested by an interface.
luckily the mixin does work, but I think that also the alias version should
work... (I find it cleaner)
I tested both in D1 and D2.
{{{
interface II{
    void f(int);
    void f(double);
}

template pr(T){
    void f(T i){
        // do something
    }
}

class A:II{
    void print(T)(T i){
        // do something
    }
    version(works){
        mixin pr!(int);
        mixin pr!(double);
    } else { // fails
        alias print!(int) f;
        alias print!(double) f;
    }
}
}}}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3472



--- Comment #1 from Fawzi Mohamed <fawzi gmx.ch> 2009-11-04 08:25:54 PST ---
For completness I forgot to say that also
{{{
alias print!(int).print f;
}}}
does not work, and with the mixin to *really* have it working you need the
mixin (that mixes in the things with the correct name to remove the interface
error), and alias (to make overloading actually work).
Definitely ugly

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2009