VC2008中返回值优化

发布于 2024-07-20 06:13:02 字数 60 浏览 4 评论 0原文

是否还有其他技术可以与 VC2008 一起使用,例如 RVO(返回值优化)或 NRVO(命名返回值优化)?

Is there other technique like RVO (return value optimization) or NRVO (named return value optimization) that can be use with VC2008?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美胚控场 2024-07-27 06:13:02

如果我是你,我不会太担心这些优化。 除此之外,它们不可携带。

如果您担心编写高效的 C++ 代码,首要规则是完全避免复制。 确保在所有可能的地方使用参考,但不要尝试在不可能的地方使用它们。 之后,有时您实际上需要一个新值 - 例如,作为operator+() 实现的返回值。

I wouldn't worry too much about those optimisations if I were you. Apart from anything else, they are not portable.

If you are worried about writing efficient C++ code, the number one rule is to avoid copying altogether. Make sure you use reference in all places where they are possible, but don't try to use them where they are not. After, all sometimes you actually need a new value - as the return value for implementations of operator+(), for example.

挽手叙旧 2024-07-27 06:13:02

也许可能对您有帮助。

但通常是编译器进行此类优化,而不是您。

Maybe this may help you.

But typically it's the compiler who does such kind of optimization, not you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文