Friday, January 13, 2012

A Quick Check for C++11 Features

The new C++11 features are exciting but I need to know which features my various compilers support, so I wrote an SCons script that tries to compile samples of new features. Seeing the samples compile is quicker, and more understandable to me, than looking up Intel's C++11 list or GCC C++0x support. Plus, I noticed that Intel's online list has almost all Yes's, but they don't list some of the Wikipedia entries that would be a No.

The SCons script, called Cpp11check, is on Github. Edit local.cfg to specify your compiler. Then run "scons" to see a summary or "scons --echo" to see every test snippet it compiles.

Looking at sample output from Intel's C++ 12.1, it looks to me like they concentrated on language features and have yet to include in the std namespace functionality that is in Boost. Seems like a decent choice. I just wish initializer lists worked. {{I, love, those, things.}}

-bash-3.2$ scons
scons: Reading SConscript files ...
INFO:SconsRoot:running with 2 threads
ERROR:SconsRoot:Could not find g++ with a version.
INFO:SconsRoot:Testing C++ compiler: /opt/intel/composer_xe_2011_sp1.6.233/bin/intel64/icpc
Checking whether the C++ compiler worksyes
Checking for c++0x conformance...-std=c++11?...-std=c++0x?...yes
Checking snippet alias templates...yes
Checking snippet alternative function syntax...yes
Checking snippet explicit final...no
Checking snippet explicit override...no
Checking snippet explicitly defaulted special member functions...yes
Checking snippet explicitly deleted member functions...yes
Checking snippet generalized_constant...no
Checking snippet hash tables...no
Checking snippet initializer lists...no
Checking snippet lambda functions...yes
Checking snippet long long int...yes
Checking snippet new string literals...no
Checking snippet nullptr...yes
Checking snippet object construction constructors calling constructors...no
Checking snippet object construction improvement using base constructor...no
Checking snippet polymorphic wrappers for function objects...no
Checking snippet random numbers...no
Checking snippet range-based for-loop...no
Checking snippet regex...no
Checking snippet right angle brackets...yes
Checking snippet shared_ptr...no
Checking snippet sizeof on member objects...yes
Checking snippet static_assert...yes
Checking snippet strongly-typed enum...yes
Checking snippet templates with variable number of values...yes
Checking snippet tuple...no
Checking snippet type inference auto...yes
Checking snippet type inference decltype...yes
Checking snippet type traits metaprogramming...no
Checking snippet uniform initialization...no
Checking snippet unrestricted unions...no
Checking snippet user-defined literals...no
Checking snippet using syntax instead of typedefs...yes
Checking snippet wrapper reference...no
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
Build succeeded.

HTH,
Drew