如何在没有明确规范的情况下从 dll 导出模板化类? [英] How do I export templated classes from a dll without explicit specification?

查看:19
本文介绍了如何在没有明确规范的情况下从 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 导出模板化类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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