如何在c ++中大量调试模板化的代码? [英] How do you debug heavily templated code in c++?

查看:204
本文介绍了如何在c ++中大量调试模板化的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现使用C ++模板元编程时我很难弄清楚我的代码有什么问题。这可能是因为我不太了解错误消息,但据我所知,我无法使用打印语句或断点来确定发生了什么。

I find it very hard to figure out what is wrong with my code when using C++ template meta-programming. It might be that I am just not very good at understanding the error messages, but as far as I'm aware I can't resort to putting in print statements or breakpoints to figure out what's going on.

您可以提供什么提示或建议,试图找出为什么某些东西不能编译,而不是手动选择代码,并希望它会来找我?

What tips or advice can you offer when trying to figure out why something is not compiling other than just picking through the code manually and hoping it will come to me?

推荐答案

对于STL,至少有可用的工具将输出更加人性化的错误消息。请参阅 http://www.bdsoft.com/tools/stlfilt.html

For the STL at least there are tools available that will output more human-friendly error messages. See http://www.bdsoft.com/tools/stlfilt.html

对于非STL模板,您只需要了解错误的含义。在你看到他们十几次之后,更容易猜到问题是什么。如果你发布他们在这里也许有人可以帮你弄清楚。

For non-STL templates you'll just have to learn what the errors mean. After you've seen them a dozen times it becomes easier to guess what the problem is. If you post them here maybe somebody can help you figure it out.

这篇关于如何在c ++中大量调试模板化的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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