cpp-cheat/cpp/template_instantiation at master · MagicRabbitTang/cpp-cheat

Template instantiation saves us from infinite compilation times because whenever you modify a header, the build system (correctly) rebuilds everything that includes that header.

They can also save object size (and likely a little bit of time) because templates are re-instantiated for each object file, unless users mark it as extern on every file, which they won't remember to do

We can also confirm with nm -C that the main.o object file does not contain a definition of MyClass, in that case because MyClass is not a complete definition because f is not defined.