g++显示从模板创建哪些类的选项
是否有一些 g++ 选项显示从模板创建哪些类?例如,原始源代码中有模板定义:
template <class T>
struct SomeStruct { T variable; };
SomeStruct<int> instance;
并且我想查看 SomeStruct< 的实现整数>。
Is there some g++ option which shows what classes are created from templates? For example there is template definition in original source code:
template <class T>
struct SomeStruct { T variable; };
SomeStruct<int> instance;
and I would like to see implementation of SomeStruct< int>.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 -fdump-class-hierarchy 标志获取该信息。它会列出比您要求的更多的内容,但如果搜索以
Class
开头的行,您就会找到您要查找的内容。编辑:这是包含
iostream
的程序的一些输出。您可以看到有char
和wchar_t
的实例化:You can get that info with the
-fdump-class-hierarchy
flag. It'll list a lot more than you're asking for, but if search for lines that start withClass
, you'll find what you're looking for.EDIT: Here's some output from a program that includes
iostream
. You can see there are instantiations ofchar
andwchar_t
:实现就像看起来一样明显:您将实际类型放入
T
中。The implementation is just as obvious as it seems: You put the real type in for
T
.