Move semantics provide a way for the contents of objects to be 'moved' between objects, rather than copied, thus significantly changing the way we design+code C++ by allowing things like return by value to be used a lot more often. Move semantics solve a couple of common issues with old C++ … Returning large objects […]

One big change to modern C++ style that comes with C++11 is that you should never need to manually delete (or free) anymore, thanks to the new classes shared_ptr, unique_ptr and weak_ptr. Note that before C++11, C++ did have one smart pointer class – auto_ptr. This was unsafe and is now deprecated, with unique_ptr replacing […]

Uniform initialization and initializer lists together provide a new common syntax for initialization in C++11. Initializer Lists Before C++11, there was no easy way to do things like initialize a std::vector or std::map (or a custom container) to a set of values. You could do so for an old C-style array, but not easily for […]

The 'range-based for' (i.e. foreach style) for loops provide C++11 with a simple for-each style loop syntax. It works with both the STL collection classes (hiding the complexity of using the STL iterator's manually), as well as with plain C arrays, and can be made to work with any custom classes as well (see Using […]

The 'auto' keyword adds type-inference to C++, such that instead of explicitly defining the type when declaring for a variable, you rather simply assign it a value/expression, and let the compiler infer the type based on what is assigned. As such, it's great at reducing verbosity, and it's a good feature to start this blog […]