D1/D2: How to check if a method has been overridden

dsimcha dsimcha at yahoo.com
Tue Sep 7 14:17:58 PDT 2010


== Quote from klickverbot (see at klickverbot.at)'s article
> On 9/7/10 11:12 PM, dsimcha wrote:
> > One way to test for overriding at runtime is to compare the function pointer of a
> > delegate obtained at runtime to the function pointer obtained from the compile
> > time type.
> That's basically the same idea I were already using, but have you tried
> implementing it for overloaded functions? I have not gotten this to work
> since there is seemingly no way to do &a.foo then.

All you need to do is provide an explicit type for the delegate:

class A {
    void fun(uint num) {}
    void fun(float num) {}
}

void main() {
    auto a = new A;
    void delegate(float) funDel = &a.fun;
}



More information about the Digitalmars-d mailing list