Generate a pointer to a method of a struct
Iain Buclaw
ibuclaw at gdcproject.org
Sat Oct 15 00:31:47 UTC 2022
On Friday, 14 October 2022 at 18:34:58 UTC, kdevel wrote:
> dmd and gdc optimize the lambda invocations away. Nonetheless
> the expression looks somewhat too big. To overcome this I tried
> to generate the function pointer outside of the struct:
>
> ```
> auto funcptr (alias method) ()
> {
> return &method;
> }
> :
> fun = funcptr!bar;
> :
> ```
>
> Which works but neither dmd nor gdc were able to optimize the
> additional function call away.
pragma(inline, true)
auto funcptr (alias method) ()
More information about the Digitalmars-d-learn
mailing list