有没有优化的c ++编译器模板使用? [英] Are there optimized c++ compilers for template use?

查看:113
本文介绍了有没有优化的c ++编译器模板使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++模板在我的日常工作中是一个祝福,因为它的力量。但是人们不能忽视由于大量使用模板(hello元编程和Boost库)而导致的(非常非常非常长的)编译时间。我已经阅读并尝试了很多可能性手动重组和修改模板代码,使其尽可能快的编译。

C++ templates have been a blessing in my everyday work because of its power. But one cannot ignore the (very very very very long) compilation time that results from the heavy use of templates (hello meta-programming and Boost libraries). I have read and tried quite a lot of possibilities to manually reorganize and modify template code to make it compile as fast as possible.

现在我想知道是否有任何c ++编译器,尽量减少解释模板类所需的时间。我可能是错的,但我觉得编译器我知道只有添加模板解释以前的版本。

Now I am wondering if there are any c++ compilers that try and minimize the needed time to interpret template classes. I might be wrong, but i feel that the compilers i do know have only added template interpretation to their previous versions.

我的问题是:


  • c ++模板代码是如此难以解释,没有太多的优化? (我非常怀疑)

  • 是否有真正优化c ++模板解释的c ++编译器?

  • 有项目开发新一代

推荐答案

似乎g ++ 4.5在处理模板方面取得了巨大的进步。这里有两个不可避免的变化。

It seems that g++ 4.5 has made tremendous progress dealing with templates. Here are the two unavoidable changes.


  • 当打印类模板特化的名称时,G ++现在将忽略来自默认模板参数的任何模板参数。 。这可以被认为是一个微妙的修改,但它将对使用c ++模板的开发产生巨大的影响(曾听说过无法读取的错误消息...?)

  • "When printing the name of a class template specialization, G++ will now omit any template arguments which come from default template arguments." That could be considered a subtle modification, but it will have an enormous impact on development with c++ templates (ever heard of unreadable error messages... ? No more !)

使用模板的代码的编译时间现在应该实例化的数量而不是二次方。这将严重破坏针对使用C ++模板的编译时参数。

"Compilation time for code that uses templates should now scale linearly with the number of instantiations rather than quadratically." This is going to severely undermine compilation-time arguments against the use of C++ templates.

请参阅 gnu网站了解完整信息

实际上,我已经在想知道是否仍然有c ++模板的问题!嗯,是的,有,但让​​我们现在关注明亮的一面!

Actually, i am already wondering whether there still are issues with c++ templates ! Mmm, yes, there are, but let's focus on the bright side for now !

这篇关于有没有优化的c ++编译器模板使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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