溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

對C++11特性支持的C編譯器有哪些

發(fā)布時間:2021-09-18 17:33:04 來源:億速云 閱讀:180 作者:柒染 欄目:編程語言

今天就跟大家聊聊有關(guān)對C++11特性支持的C編譯器有哪些,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

GCC的下個版本是4.8,以及Clang即將到來的版本是3.3 。如果你使用Visual Studio 2012,你可以安裝2012年11月更新支持C++11額外特征的體驗版CTP。

我也對V.13.0的Intel C++編譯器感到好奇,雖然它還不是預(yù)覽版并且我也找不到有關(guān)它的新特性的信息。我沒找到任何有關(guān)這個即將發(fā)行版本的編譯器的信息。

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已經(jīng)增加了好幾個重要C++11特性,像變參模板,初始化器和原生字。

我真的不能在一個更為細致的層面去評論這些編譯器實現(xiàn)到底完成得怎樣,還有沒有bug。(除了VS2012——我在我的書(《C++11 Rocks》)里詳細列出過VS2012最初版本的大量bug)。

看下庫的支持情況也是比較有用的。由于各編譯器對標準庫的支持都有較多小改動,我并不打算對此給出詳細的細節(jié)。我也打算在這次的比較中省略Intel的庫。

我可以說,這些庫的主要附件大多由第三方實現(xiàn)提供(隨后在下面的表格中展現(xiàn)),盡管這是有各種各樣的警告。

微軟的庫實現(xiàn)中沒有那些需求尚未被實現(xiàn)的語言功能的東西,例如 constexpr(如VS2012的最初發(fā)行版)。庫文件還沒有更新,以支持2012年11月在 CTP 提出的編譯器功能,如初始化列表和可變參數(shù)模板。

GCC 的 libstdc++ 也有些滯后,例如它并不支持正則表達式以及地稱并發(fā)功能。同樣,在很多情況下,它也沒有實現(xiàn) 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

比較高興的是能看到語言和庫的支持在穩(wěn)步改善。Clang和GCC距離完全支持C++11已經(jīng)很近了。Visual Studio同樣在改善對C++11的支持,令我感到欣慰的是C++編譯器的更新都是在主分支上。這份Intel的編譯器特征支持列表也越來越多。

看完上述內(nèi)容,你們對對C++11特性支持的C編譯器有哪些有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

c++
AI