检查C ++模板实例化 [英] inspect C++ template instantiation

查看:86
本文介绍了检查C ++模板实例化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一些实用程序可让我检查模板实例化?
我的编译器是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:

  • 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屋!

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