A library uses a template class TemplCls<TArg>
, and a linked executable also uses it. Now, if two source files of the same final binary (library or executable) use the template with the same parameter, then only one instantiation of the template will be kept.
What will happen if the dynamic-library and the executable both use the template? As the linker of the executable will (generally) receive a terminal option to link with the dynamic library, will it also keep in mind that the template was already instantiated in the library itself, and therefore, it need not, instantiate it into the executable?
What will happen if the dynamic-library and the executable both use the template?
Each will get get a copy of every template method that is used.
You don't need to ask this question, you could just look (in unstripped binaries):
nm -AC a.out foo.so | grep TemplCls