在 2023/4/3 18:33, Vittorio Romeo 写道:
My use case is as follows.I have a class template `S` with implicit inline functions in `lib.h`.To improve compilation times, I want to explicitly instantiate common specializations of this class template in `lib.cpp`. In order to do so, I want to provide an explicit instantiation declaration (`extern template`) of `S<int>` in `lib.h`, and an explicit instantiation definition of `S<int>` in `lib.cpp`. Now, I expect that every consumer linking against `lib` should be able to use `S<int>` without having to fully instantiate it.
That's perfect valid use.I did some experiments, compared results from explicit instantiations with non-template functions (which got exported correctly), and also with what was generated on Linux. Indeed GCC generates out-of-line copies for inline functions along with the explicit instantiation, and calls to such functions no longer result in out-of-line copies on their own. In this case, GCC should have exported such instantiated copies. I have replied on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109380, but not sure whether there have been people working it yet.
-- Best regards, LIU Hao
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
