I have two static libraries linked in a resulting executable. Both of them identically define the class template fmt::formatter<shatred_ptr<T>,char> template for formatting shared_ptr<T> (for logging purposes). The definitions are identical in each library and look like this:
#include<fmt/ostream.h>
template <typename T> struct fmt::formatter<std::shared_ptr<T>,char>: ostream_formatter {};
The template is implicitly instantiated for many different Ts.
When the executable is being linked, I get complains about multiple definition of the
error: redefinition of ‘struct fmt::v9::formatter<std::shared_ptr<_Tp>, char>’
Is there a way to tell the compiler to merge the definitions, which are token-to-token identical? I tried various things like putting inline, extern, __attribute__((visibility,"hidden")) to various places; using "object" library (as CMake calls it — I assume it meas just object archive) instead of static and others.
I will appreciate an explanation of this (yet another) c++ corner; and a minimally-invasive solution.