Using core.reflect to rewrite code

Stefan Koch uplink.coder at googlemail.com
Sat Aug 14 11:15:50 UTC 2021


On Friday, 13 August 2021 at 12:51:21 UTC, Adam D Ruppe wrote:
> On Thursday, 12 August 2021 at 04:47:52 UTC, Stefan Koch wrote:
>> Yes but I am still not quite sure how to write the equivalent 
>> template ;)
>
> You'd just loop through the members, see if there's the struct 
> pointer as the argument, and if so, generate a forwarder 
> function with the &this passed to it.
>
> Though I wouldn't generate an actual wrapper here since UFCS 
> does the same thing in practice, I have done similar in my 
> script wrapper for ufcs
>
> http://arsd-official.dpldocs.info/source/arsd.jsvar.d.html#L2480

Thanks for your input.
In the meantime I have been able to reproduce the behavior in a 
template.
`WrapperString` in the following gist 
https://gist.github.com/UplinkCoder/e60584a2c8f46ae4a490117b878ecec1

The performance of the template is roughly 2 times worse when 
compared to the `core.reflect` solution still.



More information about the Digitalmars-d mailing list