Tag Archives: Language Features

Lesson #5: Move Semantics

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 […]

Lesson #3: Uniform Initialization

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 […]

Lesson #2: Range-based 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 […]

Lesson #1: ‘auto’

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 […]