Templates may or may not have external linkage. It depends on how they were instantiated. It's perfectly possible, for example, for the shared library to use explicit instantiation to create Matrix<Foo>, Matrix<Bar>, and Matrix<Baz>. On the other hand, since a lot of the benefit of this kind of templating comes from inlining, this would probably not be the style used in a matrix multiplication library.
It's also possible for templates declared in a header file and instantiated in library client code (inline) to call functions from a shared library. This is where most of the version skew problems come from, since when the library client is linked against another version of the shared library, he will not update his inlined templates, but will be using different versions of those functions.
Posted Apr 10, 2012 9:19 UTC (Tue) by epa (subscriber, #39769)
[Link]
I'm not sure I understand you rightly, but I always thought that it was impossible for a library to provide Matrix<Foo> unless the author of the library already knew about the Foo type. If Foo is a type specific to your application, it's not going to be something your matrix library knows about. Is that no longer the case with today's C++ toolchains?
Bundled == old
Posted Apr 10, 2012 15:22 UTC (Tue) by cmccabe (guest, #60281)
[Link]
No, you can't instantiate Matrix<Foo> without knowing about type Foo. I'm just saying that there are a lot of templates out there that aren't inlined.
My biggest point, if I have one, is that mixing the inlined and non-inlined stuff is what creates the versioning problems.