How do I export templated classes from a dll without explicit specification?(如何在没有明确规范的情况下从 dll 导出模板化类?)
问题描述
我有一个包含模板化类的 dll.有没有办法在没有明确说明的情况下导出它?
I have a dll that contains a templated class. Is there a way to export it without explicit specification?
推荐答案
由于模板的代码通常在标题中,因此您根本不需要导出函数.即使用dll的库可以实例化模板.
Since the code for templates is usually in headers, you don't need to export the functions at all. That is, the library that is using the dll can instantiate the template.
这是让用户可以自由地在模板中使用任何类型的唯一方法,但从某种意义上说,它与 dll 的工作方式背道而驰.
This is the only way to give users the freedom to use any type with the template, but in a sense it's working against the way dlls are supposed to work.
这篇关于如何在没有明确规范的情况下从 dll 导出模板化类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在没有明确规范的情况下从 dll 导出模板化类?
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
