Member function pointers

Jacob Carlborg doob at me.com
Mon Jun 10 01:04:43 PDT 2013


On 2013-06-10 09:23, Manu wrote:

> That seems pretty awkward to me. Basically a hack.
> A function pointer is not a delegate, so I don't see why that should be
> used to describe one.

It depends on how you look at it. In D a delegate is a function pointer 
with a context pointer. In C++ a pointer to a member function is 
basically the same, the context pointer is just passed separately.

> Also, extern(C++) delegates are useful too in their own right

To do what? As far as I know C++ doesn't have anything corresponding to 
a D delegate.

> I haven't needed to yet... but that doesn't mean it might not be useful.
> It would probably be used in D for tight binding with other systems.
> AngelScript binds to native code with member function pointers... just
> off the top of my head.

Actually I don't see why you can't use a delegate for this. The only 
difference is that it won't be virtual.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list