Modern C++ Features

Probably everybody who has written C++03 code had the pleasure of using NULL and stumbling over one pitfall or another. C++11 brought the solution to those issues with nullptr.

Having covered the basics of `auto` and rvalue references, there is a third big new C++ feature definitely worth knowing about: creating function objects on the fly with lambda expressions.

The last weeks I have been writing a lot about move semantics, move operations, rvalue references and forwarding references. While it might take a bit of getting used to all this, there’s good news.

Combining rvalue references with templated function parameters or `auto` behaves quite differently than “normal” rvalue references. Together with the utility function template `std::forward` they allow something called “perfect forwarding” and are therefore also called forwarding references.

Modern C++ Features - Move Constructor and Move Assignment

In my last post I gave a little introduction to move semantics and a very brief description of rvalue references. This time I will cover two special functions that are based on those language features and are key to integrating them into each and every C++ program: The move constructor and move assignment operator.

One of the biggest changes in C++11 were the introduction of rvalue references to allow the implementation of move semantics. I will give an overview of the basic idea of move semantics, its related features and how to use them.