How to make closed source for the library written with template in C++

后端 未结 3 1652
青春惊慌失措
青春惊慌失措 2021-01-21 01:30

After reading this article Storing C++ template function definitions in a .CPP file, I know that the definition of a class that uses template has to be written in the header fil

相关标签:
3条回答
  • 2021-01-21 01:48
    1. The details of the template implementation will be visible. You can provide explicit template instantiations if you know which parameters will be necessary, however. But to be a generic solution, you have to provide the implementation so it can be used with other parameters.

    2. No, you don't have to release it as open source. Just because someone can see the code, doesn't mean it has to be open source. You can license it almost however you want, and the purchaser has to abide by those rules. After all, just because we can see the entire text of a novel doesn't mean we can do whatever we want with it.

    0 讨论(0)
  • 2021-01-21 01:54

    It does mean that template-based libraries normally have supply source code, yes. That isn't particularly similar to how "open source" is typically used. Then again, most good libraries supply source code in any case.

    0 讨论(0)
  • 2021-01-21 02:00

    Yes, template-based C++ libraries expose their implementations. Providing source is not the same thing as "open source." Microsoft supplies the source to MFC, but it isn't open source. The license makes the difference.

    0 讨论(0)
提交回复
热议问题