Static member variable in template, with multiple dlls

后端 未结 7 941
不思量自难忘°
不思量自难忘° 2020-12-15 19:44

My code is built to multiple .dll files, and I have a template class that has a static member variable.

I want the same instance of this static member variable to be

7条回答
  •  情歌与酒
    2020-12-15 20:07

    There exists the following solution, as well:

    • in the library: explicitly instantiate some template specialization and share them with dllexport
    • in the main program:
      • if the specialization is available it will be used from the library
      • if the specialization is not available it is compiled in the main program

    The desciption in detail how you can do this:

    Anteru's blog Explicit template instantiation

提交回复
热议问题