如何使用C ++用模板编写的库制作封闭源代码 [英] How to make closed source for the library written with template in C++

查看:43
本文介绍了如何使用C ++用模板编写的库制作封闭源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读本文将C ++模板函数定义存储在.CPP文件中后,我知道使用该类的类的定义模板必须以某种方式写入头文件中.因此,客户端用户可以通过导入头文件来使用它.这是否意味着向用户透露了完整的实施细节?这是否也意味着必须以开源方式提供使用模板编写的库?

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 file in some way. So a client user can use it by importing the header files. Doesn't this mean the complete implementation details are revealed to the user? Does this also mean a library written with template must be provided in an open-source way?

感谢您帮助澄清.

推荐答案

  1. 模板实现的详细信息将可见.但是,如果知道哪些参数是必需的,则可以提供显式的模板实例化.但是,要成为通用解决方案,您必须提供实现,以便可以与其他参数一起使用.

  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.

不,您不必将其作为开源发布.仅仅因为有人可以看到代码,并不意味着它必须是开源的.您几乎可以根据需要获得许可,购买者必须遵守这些规则.毕竟,仅仅因为我们可以看到小说的全部内容,并不意味着我们可以做任何想做的事.

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.

这篇关于如何使用C ++用模板编写的库制作封闭源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆