您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(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ā)行版本的編譯器的信息。
Feature | VS2012 Nov CTP | g++ 4.8 | Clang 3.3 | Intel 13.0 |
---|---|---|---|---|
auto | Yes | Yes | Yes | Yes |
decltype | Yes | Yes | Yes | Yes |
Rvalue references and move semantics | Yes | Yes | Yes | Yes |
Lambda expressions | Yes | Yes | Yes | Yes |
nullptr | Yes | Yes | Yes | Yes |
static_assert | Yes | Yes | Yes | Yes |
Range based for loop | Yes | Yes | Yes | Yes |
Trailing return type in functions | Yes | Yes | Yes | Yes |
extern templates | Yes | Yes | Yes | Yes |
>> for nested templates | Yes | Yes | Yes | Yes |
Local and unnamed types as template arguments | Yes | Yes | Yes | Yes |
Variadic macros | Yes | Yes | Yes | Yes |
Variadic templates | Yes | Yes | Yes | Yes |
Default template arguments in function templates | Yes | Yes | Yes | Yes |
final method keyword | Yes | Yes | Yes | No |
override method keyword | Yes | Yes | Yes | No |
Strongly typed enums | Yes | Yes | Yes | Partial |
Forward declared enums | Yes | Yes | Yes | Partial |
Initializer lists | Yes | Yes | Yes | Partial |
explicit type conversion operators | Yes | Yes | Yes | No |
Raw string literals | Yes | Yes | Yes | No |
Forwarding constructors | Yes | Yes | Yes | No |
Template aliases | No | Yes | Yes | Yes |
Defaulted methods | No | Yes | Yes | Yes |
Deleted methods | No | Yes | Yes | Yes |
New built-in types | Partial | Yes | Yes | Partial |
Alignment support | Partial | Yes | Yes | No |
Inline namespaces | No | Yes | Yes | No |
sizeof on non-static data members without an instance | No | Yes | Yes | No |
Changed restrictions on union members | No | Yes | Yes | No |
User defined literals | No | Yes | Yes | No |
Encoding support in literals | No | Yes | Yes | No |
Arbitrary expressions in template deduction contexts | No | Yes | Yes | Don’t know |
Non-static data member initializers | No | Yes | Yes | Don’t know |
noexcept | No | Yes | Yes | Partial |
constexpr | No | Yes | Yes | Partial |
C99 compatibility | Partial | Yes | Partial | Yes |
Generalized attributes | No | Yes | Partial | Yes |
Thread local storage | Partial | Yes | No | Partial |
Inheriting constructors | No | Yes | No | No |
Rvalue references for *this | No | No | Yes | No |
Minimal support for garbage collection | Yes | No | No | Don’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。
Feature | MSVC | libstdc++ | libc++ |
---|---|---|---|
Concurrency: async/future/promise/packaged_task | Yes | Yes | Yes |
Concurrency: thread and related | Yes | Yes | Yes |
Concurrency: condition variables | Yes | Yes | Yes |
Concurrency: mutexes | Yes | Yes | Yes |
Concurrency: atomic types and operations | Yes | Yes | Yes |
Concurrency: relaxed memory ordering and fences | Yes | No | Yes |
Smart pointers | Yes | Yes | Yes |
Tuples | Yes | Yes | Yes |
std::bind | Yes | Yes | Yes |
std::function | Yes | Yes | Yes |
Regular expressions | Yes | No | Yes |
Type traits | Yes | Partial | Yes |
std::forward_list | Yes | Yes | Yes |
std::array | Yes | Yes | Yes |
Hash tables | Yes | Yes | Yes |
Random number generation | Yes | Yes | Yes |
Compile time rational numbers (ratio) | Yes | Yes | Yes |
Time utilities (chrono) | Yes | Yes | Yes |
Initializer lists | Yes | Yes | Yes |
Diagnostics (system_error) | Yes | Yes | Yes |
STL refinements and new algorithms | Yes | Yes | Yes |
General purpose (move, forward, declval etc.) | Yes | Yes | Yes |
比較高興的是能看到語言和庫的支持在穩(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è)資訊頻道,感謝大家的支持。
免責(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)容。