切换到 C++11

发布于 2024-08-25 11:10:51 字数 200 浏览 4 评论 0 原文

我们将使用 C++ 作为编程语言来启动一个长期项目。

我读到 C++0x 将于 2011 年发布,所以他们称之为 C++11。

当 C++11 发布时,我们仍将开发该项目,并且想知道现在是否可以使用新 C++ 标准的任何功能,以便能够:

  • 比旧 C++ 更快地编码并
  • 轻松切换新标准什么时候到来?

We are going to start a long lasting project using C++ as the programming language.

I read that C++0x is going to come out in 2011, so they called it C++11.

When C++11 comes out, we will still be developing the project, and would like to know if it is possible to use any features of the new C++ standard now, to able to:

  • code faster than with the old C++ and
  • switch easily when the new standard arrives?

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

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

发布评论

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

评论(6

黎夕旧梦 2024-09-01 11:10:51

页面显示了 gcc(主要 Unix 编译器)支持的 C++0x 部分,MSVC(主要的微软编译器)和其他一些(包括英特尔)。 Clang 的额外信息位于 此处,尽管我认为他们对当前标准的 C++ 支持仍然不完整。

This page shows the parts of C++0x supported by gcc(main Unix compiler), MSVC(main Microsoft compiler) and a few others(including Intel). Extra info for Clang is here although I think their c++ support for current standards is still incomplete.

人事已非 2024-09-01 11:10:51

仅仅因为标准的出现并不意味着编译器会神奇地得到更新 - 大多数编译器花了数年时间才为以前的标准提供合理的支持,并且某些功能从未得到太多支持,例如导出(从 C++0x 中删除) 。依赖于新功能的首次实现也不是一个好的策略 - 如果我要在截止日期前完成工作,我更愿意让其他人成为实验者。

另外,我不会太快地将其称为 C++11 - 标准流程充满了延迟的可能性。

编辑:我看到您正在使用 RW 库。在这种情况下,新标准的许多功能可能不会立即引起人们的兴趣,因为它们针对的是模板编写者和 C++ 标准库的用户。

Just because a standard comes out does not mean that the compilers magically get updated - it took years for most compilers to provide reasonable support for the previous standard, and some features never got supported much, such as export (dropped from C++0x). Depending on first implementations of new features si not a great strategy either - I prefer to let others be experimenters, if I'm working to a deadline.

Also, I wouldn't be too fast to call it C++11 - the standards process is fraught with possibilities for delay.

Edit: I see you are using the RW libraries. In which case, probably many features of the new Standard won't be of immediate interest, as they are aimed at template writers and users of the C++ Standard library.

牵你手 2024-09-01 11:10:51

Visual C++ 2010 和最新的 gcc 版本 (-std=c++0x) 支持 C++11 的新功能,但不是全部。特别是,您可以开始使用带有大括号的新初始化语法;恕我直言,这是 C++11 中最大的语法变化。如果一部分使用 C++98 样式而另一部分使用 C++11 样式,那么这一更改也会在代码中增加最多的不一致之处。

Visual C++ 2010 and latest gcc versions (-std=c++0x) have support for new features of C++11, but not all of them. In particular, you could start using the new initializer syntax with braces; that is IMHO the biggest syntax change in C++11. It is also the change that would add the most inconsistencies in your code, if one part uses C++98 style and the other uses C++11 style.

风流物 2024-09-01 11:10:51

Scott Meyers(“Effective C++”系列的作者)上周刚刚上传了以下内容:

gcc 和 MSVC 中的 C++0x 功能可用性摘要

从某种意义上说,这与另一个 链接 在此线程的另一个答案中提到。主要区别在于迈耶斯的链接仅包含他自己尝试过的内容。我预计它将在未来几个月内不断更新。

另外,我也是这样发现的,他comp.std.c++ 暗示他正在研究与 C++0x 教育材料相关的内容(显然超出了他的培训课程),但这现在都太投机了,所以让我们坚持我的第一个链接上面提供了。

Scott Meyers (author of the "Effective C++" series) uploaded just last week the following:

Summary of C++0x Feature Availability in gcc and MSVC

This is, in a sense, similar to another link mentioned in a different answer on this thread. The main difference is that Meyers' link only contains stuff he's tried out himself. I expect it will keep getting updated in the months to come.

Also, and this is how I found out about this, he implied on comp.std.c++ that he is working on something related to C++0x educational material (apparently beyond his training course) but this is all too speculative right now, so let's just stick to the first link I provided above.

凶凌 2024-09-01 11:10:51

不要将其视为立即切换到所有新功能。根据每个新语言特性的优点及其实现的质量来评估它。

例如,long long 甚至在被考虑用于 C++0x 之前就已经是相当常见的编译器扩展,并且新的 auto 语法非常有用并且可能得到良好支持。您可能需要非常谨慎地对待几个新功能的复杂组合,例如使用可变参数模板在类中使用新 -> 语法的函数使用 decltype 进行类型推断以及解析 >> 的新规则。

Don't think of it as switching to all the new features at once. Evaluate each new language feature on it's own merits, and the quality of its implementation.

For instance long long has been a fairly common compiler extension even before it was considered for C++0x, and the new auto syntax is useful and likely to be well-supported. You may want to be very cautious with some complicated combination of several new features like type inference with decltype for a function with the new -> syntax inside a class using variadic templates and the new rules for parsing >>.

两仪 2024-09-01 11:10:51

这取决于您使用的编译器。

例如,GCC 具有 tr1 扩展,其中包含 C++11 中的一些功能。

it depends which compiler you are using.

As an example, GCC has the tr1 extension which contains some features that will be in C++11.

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