virtual method pointer

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Thu May 3 13:23:08 PDT 2012


No, I intend to call these methods very frequently and I can't afford
any performance loss.

What I expect to have is something like a virtual table entry. I tied
looking at the virtual tables and searching for the method delegate's
.funcptr in the vtable, but didn't find it.

Having that vtable entry would allow me to

On Thu, May 3, 2012 at 11:23 PM, Timon Gehr <timon.gehr at gmx.ch> wrote:
> On 05/03/2012 09:18 PM, Gor Gyolchanyan wrote:
>>
>> So, you're saying, that the foo function actually takes the *this,
>> which we ass manually, extracts the real foo method and calls it?
>> AFAIK, that shouldn't be the case. The delegate extracts the A's foo
>> and call to the delegate should be a direct call to A.foo, not a
>> virtual call.
>>
>
> I just gave an alternative to Alex' solution, but it seems both do not
> actually do what you are after.
>
> Is this good enough?
>
> auto fn = function(A a){return a.foo();}
>
> fn(a);
> fn(b);



-- 
Bye,
Gor Gyolchanyan.


More information about the Digitalmars-d mailing list