Given an object, how to call an alias to a member function on it?

Nick Treleaven nick at geany.org
Wed May 3 11:13:46 UTC 2023


On Tuesday, 2 May 2023 at 13:06:41 UTC, ag0aep6g wrote:
> void fun(alias method)(C c)
> {
>     void delegate() dg;
>     dg.funcptr = &method;
>     dg.ptr = cast(void*) c;
>     dg();
> }

This also works:

void fun(alias method)(C c)
{
     void delegate() dg = &c.method;
     dg();
}



More information about the Digitalmars-d-learn mailing list