A comparison of C++11 language support in VS2012, g++ 4.7 and Clang 3.1


If you need an excuse for celebration, today happens to be an anniversary! The C++11 standard was approved by ISO on 12 August last year, exactly one year ago. I decided to take a look at the state of C++11 language support one year on across three compilers: the upcoming VS11 (Visual Studio 2012), g++ 4.7 and Clang 3.1.

Please note I didn’t detail the non-language concurrency changes. Generally, support for those remains limited.

Feature VS11 g++ 4.7 Clang 3.1
auto Yes Yes Yes
decltype Yes Yes Yes
Rvalue references and move semantics Yes Yes Yes
Lambda expressions Yes Yes Yes
nullptr Yes Yes Yes
static_assert Yes Yes Yes
Range based for loop Yes Yes Yes
Trailing return type in functions Yes Yes Yes
final method keyword Yes Yes Yes
override method keyword Yes Yes Yes
Strongly typed enums Yes Yes Yes
Forward declared enums Yes Yes Yes
extern templates Yes Yes Yes
>> for nested templates Yes Yes Yes
Local and unnamed types as template arguments Yes Yes Yes
Variadic macros Yes Yes Yes
New built-in types Partial Yes Yes
Initializer lists No Yes Yes
explicit type conversion operators No Yes Yes
Inline namespaces No Yes Yes
sizeof on non-static data members without an instance No Yes Yes
Changed restrictions on union members No Yes Yes
Raw string literals No Yes Yes
User defined literals No Yes Yes
Encoding support in literals No Yes Yes
Arbitrary expressions in template deduction contexts No Yes Yes
Defaulted methods No Yes Yes
Deleted methods No Yes Yes
Non-static data member initializers No Yes Yes
Variadic templates No Yes Yes
Default template arguments in function templates No Yes Yes
Template aliases No Yes Yes
Forwarding constructors No Yes Yes
noexcept No Yes Yes
constexpr No Yes Yes
Alignment support Partial No Yes
Rvalue references for *this No No Yes
C99 compatibility Partial Partial Partial
Thread local storage Partial Partial No
Inheriting constructors No No No
Generalized attributes No No No

Clang is leading with the most C++11 features implemented, and Visual Studio is unfortunately lagging behind. Still, there is a decent subset of features already available for cross-platform development using these three compilers.

You can use type inference, move semantics and rvalue references, nullptr, static_assert, and range-based for loop.

You can have finer control over inheritance using final and override keywords. Enums can be strongly typed and forward declared. There are several improvements to templates, including the extern keyword.

Sadly, the much requested variadic templates aren’t available in Visual Studio. Variadic macros, on the other hand, are implemented in all three compilers for C99 compatibility.

The features that aren’t implemented anywhere are inheriting constructors and generalized attributes. Thread local storage is at best partially supported (via non-standard keywords).

Overall, I think this represents good progress and shows that at least a subset of C++11 can be used today for cross-platform projects.


Keen on mastering C++11/14? I’ve written a book about the C++11/14 features. You can get a VS2013, Clang or a GCC edition.


21 Responses to “A comparison of C++11 language support in VS2012, g++ 4.7 and Clang 3.1”

  1. Thanks for the overview. What about Memory Model and all the concurrency features? The last time I checked GCC was mostly done with C++11 but lacking in concurrency support, probably because this is the most complicated stuff.


    • I omitted those things because they aren’t really part of the language itself. Perhaps I’ll write a post detailing the state of the libraries later.

      • Alex Korban
      • I am also interested in the concurrency (library) features.

        Last time I tried it was very frustrating making C++11 (windows) concurrency code play with C++11 gcc4.7.2

        As far as I know there is no comparison between the concurrency parts between MS / Clang / GCC,. so you could be first :)

  2. This is desperately missing color coded cells :(
    So is the linked wiki at apache.org.

  3. An extremely useful comparison, thank you for taking the time to do this. MS obviously had to focus on C++/CX and WinRT to e exclusion of C++ lest they lose even more ground to iOS and Android, but I really hope they fill out their C++ 11 support soon… and allow us to target the millions of Windows XP desktops with C++ 11 without this side-by-side nonsense. Let’s hope they deliver on both of these soon if not sooner.

    • libc++ is feature complete except for a tiny bit of localization. clang 3.1 also supports libstdc++ in C++11 mode.

      • Michael Spencer
  4. It’s a shame on MS that they still doesn’t have variadic templates implemented.
    Regarding clang 3.1. The compiler itself is good enough to be used for some real application, BUT…
    For this moment the lack of own complete STL (i.e. libc++) and not full support of GNU STL (i.e. libstdc++) with -std=c++11, in particular , makes clang still not ready for usage as g++ replacement.

    • Igor
    • …in the upper message, after “in particular” the “atomic” was removed by site engine for some reasons :)

      • Igor
      • I am using Clang/libc++ as shipped with XCode 4.4.1 and I can assure that atomics are fully supported on MacOS and iOS. I understand that atomics are platform-dependent, so I can’t say whether support is also avaiable on other platforms.

        • iaanus
  5. What a shame MS!!!!

    • Zid
  6. It’s a shame MS is lagging behind. Recently I gave up on ensuring compilation in both gcc and vs, and switched purely to gcc. Thanks for these useful regular comparisons Alex.

    • bman
    • I prefer to take an optimistic view. Quite a few features _are_ available in VS2012, in particular the most popular ones such as lambdas, move semantics and _auto_.

      • Alex Korban
  7. Coming in November, available to try now:


    uniform initialization, initializer lists, variadic templates, function template default arguments, delegating constructors, explicit conversion operators and raw strings.

    Some progress! And not to long a wait!

    • Michael Tomlinson
    • Yes, it’s quite exciting!

      • Alex Korban