- Final Class: C++11 provides the
finalspecifier to prevent class derivation - C++11 lambdas substantially reduce the need for named function object (functor) classes.
- Move Constructor: The magical ways in which
std::auto_ptrworks are no longer needed due to first-class support for rvalue references. - Safe bool: This was mentioned earlier. Explicit operators of C++11 obviate this very common C++03 idiom.
- Shrink-to-fit: Many C++11 STL containers provide a
shrink_to_fit()member function, which should eliminate the need swapping with a temporary. - Temporary Base Class: Some old C++ libraries use this rather complex idiom. With move semantics it’s no longer needed.
- Type Safe Enum Enumerations are very safe in C++11.
- Prohibiting heap allocation: The
= deletesyntax is a much more direct way of saying that a particular functionality is explicitly denied. This is applicable to preventing heap allocation (i.e.,=deletefor memberoperator new), preventing copies, assignment, etc. - Templated typedef: Alias templates in C++11 reduce the need for simple templated typedefs. However, complex type generators still need meta functions.
- Some numerical compile-time computations, such as Fibonacci can be easily replaced using generalized constant expressions
result_of: Uses of class templateresult_ofshould be replaced withdecltype. I thinkresult_ofusesdecltypewhen it is available.- In-class member initializers save typing for default initialization of non-static members with default values.
- In new C++11 code
NULLshould be redefined asnullptr, but see STL’s talk to learn why they decided against it. - Expression template fanatics are delighted to have the trailing return type function syntax in C++11. No more 30-line long return types!
I think I’ll stop there!