Visual Studio, GCC, Clang, Intel 对 C++11 特性的支持一览表

4 篇文章 0 订阅

距离我上次对C++11支持的不同编译器的比较已经有大半年了。这次我来根据这些预览版的编译器的文档来看下它们是如何堆砌起来的。

GCC的下个版本是4.8,以及Clang即将到来的版本是3.3 。如果你使用Visual Studio 2012,你可以安装2012年11月更新支持C++11额外特征的体验版CTP。

我也对V.13.0的Intel C++编译器感到好奇,虽然它还不是预览版并且我也找不到有关它的新特性的信息。我没找到任何有关这个即将发行版本的编译器的信息。
FeatureVS2012
Nov CTP
g++ 4.8Clang 3.3Intel 13.0
autoYesYesYesYes
decltypeYesYesYesYes
Rvalue references and move semanticsYesYesYesYes
Lambda expressionsYesYesYesYes
nullptrYesYesYesYes
static_assertYesYesYesYes
Range based for loopYesYesYesYes
Trailing return type in functionsYesYesYesYes
extern templatesYesYesYesYes
>> for nested templatesYesYesYesYes
Local and unnamed types as template argumentsYesYesYesYes
Variadic macrosYesYesYesYes
Variadic templatesYesYesYesYes
Default template arguments in function templatesYesYesYesYes
final method keywordYesYesYesNo
override method keywordYesYesYesNo
Strongly typed enumsYesYesYesPartial
Forward declared enumsYesYesYesPartial
Initializer listsYesYesYesPartial
explicit type conversion operatorsYesYesYesNo
Raw string literalsYesYesYesNo
Forwarding constructorsYesYesYesNo
Template aliasesNoYesYesYes
Defaulted methodsNoYesYesYes
Deleted methodsNoYesYesYes
New built-in typesPartialYesYesPartial
Alignment supportPartialYesYesNo
Inline namespacesNoYesYesNo
sizeof on non-static data members without an instanceNoYesYesNo
Changed restrictions on union membersNoYesYesNo
User defined literalsNoYesYesNo
Encoding support in literalsNoYesYesNo
Arbitrary expressions in template deduction contextsNoYesYesDon’t know
Non-static data member initializersNoYesYesDon’t know
noexceptNoYesYesPartial
constexprNoYesYesPartial
C99 compatibilityPartialYesPartialYes
Generalized attributesNoYesPartialYes
Thread local storagePartialYesNoPartial
Inheriting constructorsNoYesNoNo
Rvalue references for *thisNoNoYesNo
Minimal support for garbage collectionYesNoNoDon’t know
看起来GCC正取代Clang成为最支持C++11的编译器。Visual Studio已经增加了好几个重要C++11特性,像变参模板,初始化器和原生字。

我真的不能在一个更为细致的层面去评论这些编译器实现到底完成得怎样,还有没有bug。(除了VS2012——我在我的书(《C++11 Rocks》)里详细列出过VS2012最初版本的大量bug)。

看下库的支持情况也是比较有用的。由于各编译器对标准库的支持都有较多小改动,我并不打算对此给出详细的细节。我也打算在这次的比较中省略Intel的库。

我可以说,这些库的主要附件大多由第三方实现提供(随后在下面的表格中展现),尽管这是有各种各样的警告。


微软的库实现中没有那些需求尚未被实现的语言功能的东西,例如 constexpr(如VS2012的最初发行版)。库文件还没有更新,以支持2012年11月在 CTP 提出的编译器功能,如初始化列表和可变参数模板。

GCC 的 libstdc++ 也有些滞后,例如它并不支持正则表达式以及地称并发功能。同样,在很多情况下,它也没有实现 constexpr 方法。


Clang的libc++是100%兼容MacOS的,但是它有部分的特性还不兼容Windows和Linux。

FeatureMSVClibstdc++libc++
Concurrency: async/future/promise/packaged_taskYesYesYes
Concurrency: thread and relatedYesYesYes
Concurrency: condition variablesYesYesYes
Concurrency: mutexesYesYesYes
Concurrency: atomic types and operationsYesYesYes
Concurrency: relaxed memory ordering and fencesYesNoYes
Smart pointersYesYesYes
TuplesYesYesYes
std::bindYesYesYes
std::functionYesYesYes
Regular expressionsYesNoYes
Type traitsYesPartialYes
std::forward_listYesYesYes
std::arrayYesYesYes
Hash tablesYesYesYes
Random number generationYesYesYes
Compile time rational numbers (ratio)YesYesYes
Time utilities (chrono)YesYesYes
Initializer listsYesYesYes
Diagnostics (system_error)YesYesYes
STL refinements and new algorithmsYesYesYes
General purpose (move, forward, declval etc.)YesYesYes


比较高兴的是能看到语言和库的支持在稳步改善。Clang和GCC距离完全支持C++11已经很近了。Visual Studio同样在改善对C++11的支持,令我感到欣慰的是C++编译器的更新都是在主分支上。这份Intel的编译器特征支持列表也越来越多

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值