title: Compile header-only template library into a shared library?
body: <p>We are in the process of designing a new C++ library and decided to go with a template-based approach along with some specific partial template specialisations for corner cases. In particular, this will be a <strong>header-only template library</strong>.</p>
  
  <p>Now, there is some concern that this will lead to a lot of <strong>code duplication</strong> in the binaries, since this template 'library'  will be compiled into any other shared library or executable that uses it (arguably only those parts that are used). I still think that this is not a problem (in particular, the compiler might even inline things which it could not across shared library boundaries).</p>
  
  <p>However, since we know the finite set of types this is going to be used for,  <strong>is there a way to compile this header into a library, and provide a different header with only the declarations and nothing else?</strong> Note that the library must contain not only the generic implementations but also the partial specialisations..</p>