It’s been more than half a year since my last comparison 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.

FeatureVS2012 Nov CTPg++ 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
Generalized attributesNoYesYesYes
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 compatibilityPartialPartialPartialYes
Thread local storagePartialYesNoPartial
Inheriting constructorsNoYesNoNo
Rvalue references for *thisNoNoYesNo

It looks like GCC is overtaking Clang as the compiler with the best C++11 support. Visual Studio has added several significant C++11 features such as variadic templates, initializer lists and raw literals.

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.

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
Minimal support for garbage collectionYesNoNo

It’s good to see that the language and library support is steadily improving. Clang and GCC are getting close to having full C++11 support. Visual Studio is also improving C++11 support, and I’m pleased that C++ compiler updates are happening between major 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!