Andrej Mitrovic wrote: > On 9/8/11, zeljkog <[email protected]> wrote: >> alias toUTFz!(const(wchar)*, string) toUTF16z; >> alias toUTFz!(const(wchar)*, wstring) toUTF16z; > > I think one difference (if I'm right) is that using a non-templated > function such as this: > > const(wchar)* toUTF16z(string s) > { > return toUTFz!(const(wchar)*)(s); > } > > can enable me to pre-compile a module to an object file (call it > unicode.obj), while using an alias the object code for toUTF16z has to > be generated when the client module (main.d) is compiled. Did some a simple test [1] and looks like the alias alone should work. I think the rule is the template code is included if it is instantiated and aliasing the template seems to be classed as instantiating it.
[1] I am not great with linkers + asm so just incase I've made an obvious mistake... I created a very basic template function (tempFunction) then compiled it as a lib with and without an alias. I extracted the object files from the libs using ar and the one with the alias contained an additional object file with the mangled name of my function (_D4test1d22__T12tempFunctionTAyaZ12tempFunctionFAyaZv:).
