C++11编译器支持列表
2016-04-17 09:13
393 查看
C++11 compiler support shootout: Visual Studio, GCC, Clang, Intel
It’s been more than half a year since my lastcomparison of the C++11 support across different compilers. This time I’d like to see how different compilers stack up based on the documentation for the pre-release versions of these compilers.
The next release of GCC is 4.8 and the upcoming version of Clang is 3.3. If you use Visual Studio 2012, you can install an experimental CTP update released in November 2012 to get additional C++11 features.
I’ve also thrown in v.13.0 of Intel’s C++ compiler out of curiosity, although it isn’t pre-release and there were a few features I couldn’t find information about. I didn’t find any information about the upcoming version of this compiler.
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 |
Generalized attributes | 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 | Partial | Partial | Yes |
Thread local storage | Partial | Yes | No | Partial |
Inheriting constructors | No | Yes | No | No |
Rvalue references for *this | No | No | Yes | No |
I can’t really comment on how complete and bug-free these implementations are at a more fine grained level (other than VS2012 - I detail a lot of the bugs in the initial VS2012 release in my book, C++11
Rocks).
It’s also useful to look at the state of library support. I’m not going to get very specific as there are lots of small changes across the standard library. I’m also going to omit Intel’s library from this comparison.
I can say that the major additions to the library are mostly provided by all three implementations (as shown in the table below), although with various caveats.
Microsoft’s library implementation lacks anything that requires unimplemented language features such as constexpr (as of the initial release of VS2012). The library hasn’t been updated to use the features in the November 2012 CTP of the compiler such as initializer
lists or variadic templates.
GCC’s libstdc++ lags somewhat as it doesn’t support regular expressions and low-level concurrency features. It also doesn’t implement constexpr methods in a lot of cases. std::function doesn’t have support for custom allocators, as Gilad noted in the comments
below.
Clang’s libc++ is 100% complete on Mac OS, however various parts of it don’t yet work on Windows and 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 |
Minimal support for garbage collection | Yes | No | No |
releases. The list of supported features in Intel’s compilers is growing longer as well.
Who knows, by next year all four compilers might support all the C++11 features!
相关文章推荐
- c++入门第一篇:hello,world!
- C++开发环境
- sizeof和strlen的一些理解
- c++对象模型阅读笔记
- C++学习笔记
- C++字符串完全指南
- VC++6.0中编写Unicode编码的应用程序
- (c++ 递归)先序 中序 还原二叉树
- C++primer 练习15.15
- [LeetCode]89. Gray Code
- 栈的链表表示
- c++作业3
- c++第3次实验
- Josephus问题
- C++初始化列表
- 正整数的中文读法(C++ Python)
- C++ STL之 vector的capacity和size属性区别
- Memory Leak Detection in C++
- C语言宏定义的使用
- 设计模式中的抽象工厂模式&c++