Learn the new C++11 features by examples.
Note: this repository is a few years old now and not really maintained anymore. My ongoing work on a C++14 repository is here: https://github.com/daniel-j-h/cpp14-snippets
Source for the references is the free N3337 working draft (pdf), dated 16 January 2012
file | reference | description |
---|---|---|
algorithms.cpp | [algorithms] | algorithm on container, using lambda |
aliastemplates.cpp | [temp.alias] | alias templates |
array.cpp | [array] | constant size array container |
auto.cpp | [dcl.spec.auto] | auto type-specifier for variables |
chrono.cpp | [time.syn] | time utilities |
constexpr.cpp | [expr.const] | compile time and run time const |
defaultdelete.cpp | [dcl.fct.def.general] | defaulted and deleted definition |
defaultfunctiontemplates.cpp | [temp.param] | default arguments in function templates |
delegation.cpp | [class.base.init] | delegating constructor |
enumeration.cpp | [dcl.enum] | type-safe enumerations |
file.cpp | [iostreams.base] | file stream |
foreach.cpp | [stmt.ranged] | range-based for |
forwardlist.cpp | [forwardlist] | single linked list |
future.cpp | [futures] | asynchronous results |
hashtable.cpp | [unord.general] | hashtable |
initializer.cpp | [support.initlist] | initializer lists |
lambda.cpp | [expr.prim.lambda] | simple function objects |
literals.cpp | [lex.ext] | user defined literals |
math.cpp | [c.math] | math functions |
move.cpp | [class.copy] | move semantic |
mutex.cpp | [thread.mutex] | synchronization |
nullptr.cpp | [lex.nullptr] | null |
overridefinal.cpp | [class.virtual] | identifier |
random.cpp | [rand] | random number generation |
referencewrapper.cpp | [ref_wrap] | reference wrapper |
regex.cpp | [re] | regular expressions |
rightbrackets.cpp | [diff.cpp03.temp] | removed template whitespace |
rvalues.cpp | [basic.lval] | lvalues, rvalues |
smartpointer.cpp | [smartptr] | smart memory management |
staticassert.cpp | [dcl.dcl] | compile time assertions |
stringliterals.cpp | [lex.string] | string literals |
thread.cpp | [thread.threads] | threading |
tokens.cpp | [lex.digraph] | alternative tokens |
trailingreturntype.cpp | [dcl.decl] | trailing return type |
trigraph.cpp | [lex.trigraph] | alternative sequences |
tuple.cpp | [tuple] | tuples |
valarray.cpp | [numarray] | numeric arrays |
variadictemplates.cpp | [temp.variadic] | variadic templates |
- cd src
- make -j 4
Please see the documentation on what's currently supported by your compiler
e.g. the initializer list code compiles only with g++ >= 4.4 or clang++ >= 3.1, which in the latter case is a rather current version