0 cost template instantiation
Hipreme
msnmancini at hotmail.com
Thu Sep 30 02:31:50 UTC 2021
On Thursday, 30 September 2021 at 02:22:35 UTC, jfondren wrote:
> On Thursday, 30 September 2021 at 01:44:57 UTC, jfondren wrote:
>> On Thursday, 30 September 2021 at 01:09:47 UTC, Hipreme wrote:
>>> I have a template function that all it does is given a
>>> symbol, it loads a dll for its type + its name:
>>>
>>> ```
>>> void loadSymbol(alias s, string symName = "")()
>>> {
>>> static if(symName == "")
>>> s = cast(typeof(s))_loadSymbol(_dll, (s.stringof~"\0").ptr);
>>> else
>>> s = cast(typeof(s))_loadSymbol(_dll, (symName~"\0").ptr);
>>> }
>>> ```
>>
>> If symName is always a string literal, then you don't need to
>> append a "\0"; string literals always have a trailing NUL
>> after them, and they autoconvert to const(char)[] so you don't
>> need the .ptr either.
>
> Playing around with this, with a mock-up of your code, doesn't
> change object size at all.
>
> Is the actual source available, that you're seeing this with?
https://github.com/MrcSnm/HipremeEngine/tree/hotload/api
You may try messing at the module api.graphics.g2d.renderer2d
There is a function called initG2D
Try changing it from loadSymbols to each one loadSymbol.
You can just dub at the folder api.
More information about the Digitalmars-d-learn
mailing list