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
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- c++ STL设置差异 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
