To learn new C++11 features, I made a few minimal working examples (MWE) to cover each one (and only one) C++11 highlight.
Compilation is done via CMake
. If you've never used it (which you should!), this gets you started from the cloned repository:
mkdir bin
cd bin
cmake ../
make
Individual highlights / files can be compiled with make highlight
, so, e.g., make lambda
.
Feel free to create a pull request or drop some comments in the issues section. This repository surely does not highlight all C++11 feature, just the ones I found most interesting and wanted to know more about.
auto.cpp
– Highlights the new auto specifier to automatically deduce the type of an object.rangeFor.cpp
– The new, handyfor
loops.beginend.cpp
— The newbegin()
andend()
syntax.initialization.cpp
— The new universal initialization syntax with curly braces. Also:std::initializer_list
for initializing of custom classes.lambda.cpp
— Lambda functions.array.cpp
— Newstd::array
, a modern replacement for C-style arrays, for arrays of constant size.smartpointers.cpp
— All the new smart pointer glory of C++11;unique_ptr
,shared_ptr
,weak_ptr
. Also, a quick reference tonullptr
.classes.cpp
— New class-annotating keywordsoverride
,final
,default
,delete
.constexpr-static_assert.cpp
– Compile-time resolved constant expressions withconstexpr
and assertion.constructors.cpp
– Constructor delegation.