Templates Exports in Modules C++

Viewed 102

I have a templated class in a module file and when exporting the module it works fine, however when importaing I get a COMDAT exception. Are there specific constraints on how to export templated classes out of modules. I saw this post, however it seems not to solve the COMDAT exception I receive. My code has the following Layout:

export namespace Foo {
    template <typename T>
    class Bar {
      ...
    }
}

However, when I link it with my GoogleTest Project and compile that one I receive a:

LNK1179 invalid or corrupt file: duplicate COMDAT '??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z' ...

Finally, I tried a template class<std::string> at the end of the namespace but that seems

  1. Not working first off, still same exception
  2. Not expandable if I have to modify my .ixx for everything

Lastly, I'm using C++ 20 with MSVC v143 compiling to a static library. Is there anything I'm missing?

0 Answers
Related