How can I use C++ 11 features in Clang?

C++C++11Clang

C++ Problem Overview


How can I use the latest C++ 11 features in Clang? What (sub)set of features is supported?

C++ Solutions


Solution 1 - C++

You will need clang 3.3 to use the most relevant feature set from C++ 11. Read C++ Support in Clang for the complete list of up-to-date supported features. Clang 3.3 is claimed to be C++11 feature complete.

Clang's command line is gcc-compatible so you have to enable C++11 support via the followinf command-line switch

-std=c++11

There is also a bunch of post-C++11 features (like decltype(auto), member initializers and aggregates) that are supported by Clang 3.3. Use this command line switch to enable them

-std=c++1y

Solution 2 - C++

Here is the always up to date list of features supported by clang:

http://clang.llvm.org/cxx_status.html

To activate C++11, you have to add -std=c++11 in your clang calls, like for gcc. If you use an IDE that is clang-aware or gcc-aware, there is a specific project settings option available to do that.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1368198View Question on Stackoverflow
Solution 1 - C++Sergey K.View Answer on Stackoverflow
Solution 2 - C++KlaimView Answer on Stackoverflow