Hello out there,
Im currently looking after saving quite a few Kb of memory and came across something strange. Large parts of my codebase are written as C++ Templates which by itself is nothing bad, but if i use the same template again in another corner of my software the resulting binary size suggests that the template is instantiated again. This same template with the same args was already used somewhere else. With this in mind i come to the conclusion, that instantiated templates are not by default reused but rather instantiated in place again. Any tips how to avoid such behaviour? Maybe template specialization is the right thing to obtain an object file with the specialized template contents. My thought is to offload the linker doing it that way. Maybe someone can shine some light on the internals of the compiler/linker regarding the issue.
Kind Regards Tobias