Writing generic code using C++ templates brings many inconveniences. I've recently decided to tackle 2 of them that irritates me the most: The namespace pollution caused by bringing to much dependencies into header files, and the necessity of recompiling the whole project after changing even a slight implementation detail in a function template.

Luckily, Explicit Template Instantiation helps here, as it can be used to explicitly tell the compiler when it should generate a definition from a template. So the definitions can be pre-generated into object files, without polluting the headers. The example below demonstrates the technique: