检查C ++模板实例化 [英] inspect C++ template instantiation
问题描述
是否有一些实用程序可让我检查模板实例化?
我的编译器是g ++或Intel。
Is there some utility which would allow me to inspect template instantiation? my compiler is g++ or Intel.
我想要的特定点:
- 逐步实例化。
- 实例化追溯(可以通过崩溃的编译器破解。更好的方法?)
- 检查模板参数。
@gf帮助我进行了简单的类型打印, C ++模板名称漂亮打印 。
@gf helpd me with simple type printing, C++ template name pretty print.
但是,由于我进入了增强凤凰和模板级别,因此很难理解发生了什么,我想使用智能解决方案
However I am getting into boost phoenix and template level makes it very hard to understand what is going on and I would like intelligent solution
还可以,如果您有一些检查模板实例化的技术,请您分享一下。
also, if you have some techniques inspecting template instantiation, can you please share them.
谢谢
推荐答案
使用模板,我们根本没有干净的输出工具,而且我不知道有哪个编译器可以直接查看模板实例化。我发现与元程序调试最接近的是一篇论文
With templates we simply don't have clean output facilities and there are no compilers i know of that allow you to directly view template instantiations. The closest i found regarding metaprogram debugging was a paper on Templight.
目前最好的工具似乎是:
For now the best utilities seem to be:
- 静态断言& 概念检查(显然要假设您的假设)
- 提到的实例化回溯(例如,通过使用静态断言)
- 让实例化生成警告(
boost :: mpl :: print
可能会做到) - 跟踪器,一个自定义类,作为模板参数传递,用于发出运行时输出(由 C ++模板-完整指南)
- static asserts & concept checks (clearly assert your assumptions)
- the mentioned instantiation backtraces (e.g. by using static asserts)
- letting instantiations generate warnings (
boost::mpl::print
might do it) - a tracer, a custom class that gets passed as a template argument and is used to emit runtime output (introduced by C++ Templates - The Complete Guide)
这篇关于检查C ++模板实例化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!