0 cost template instantiation
Basile B.
b2.temp at gmx.com
Thu Sep 30 01:56:42 UTC 2021
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);
> }
> ```
>
>
> The main problem is that this function is costing 2KB per
> instantiation, which is something pretty high. Specially if I
> inline, there is almost no cost when compared to its inline
> version. Trying to use pragma(inline, true) didn't do anything
> too.
cant you just use a regular functions ? loading happens at
runtime right ?
More information about the Digitalmars-d-learn
mailing list