REVIEW - C++ Move Semantics - The Complete Guide


C++ Move Semantics

The Complete Guide


Nicolai Josuttis


leanpub (2020)




Paul Floyd


March 2021



Verdict: Highly recommended.

You may be wondering, how can someone stretch an extra & (plus std::move and std::forward) to over 200 pages?

Well, ‘without much difficulty’ is now my answer.

Before I read the book, I wondered if it would read well on its own, or whether it would work best when associated with a training course. My conclusion was that the book works well on its own, somewhat in the style of Scott Meyers without the jokey widget references.

The book starts Chapter 1 well with a concrete example of the reduction in the number of copies that occur for the same code when compiled pre-C++11 without move semantics and post-C++11 with C++ semantics. This is nicely illustrated with diagrams showing what the memory looks like as the code executes. Considering that the book is self-published and written in LaTeX, this is very impressive.

Chapters 2 and 3 explain the basic use of rvalue references and how they have changed class special functions by adding the move constructor and move assignment operator. Chapter 4 explains where to use rvalue references and std::move and also where not to use them. The next few chapters cover overloading issues, what happens to moved from objects and interaction with noexcept. The going is getting a bit tougher. The last Chapter – 8 – of Part 1 covers Value Categories. xvalues, prvalues and all that. I thought that it was a good thing to cover this as late as possible and to have plenty of practical explanations under the belt.

Part II contains four chapters on move semantics and generic coding – && meets templates resulting in universal/forwarding references. I admit that when I first read about this kind of reference, I didn’t really twig that it was different from ordinary rvalue references. I found this explanation (both of why it is required and then the mechanics) to be clear and concise.

Finally, Part III covers how the Standard Library has been extended to use rvalue references. This includes move-only types such as threads and files that you aren’t too likely to encounter in user-written code.

In conclusion, I think that this book would well suit an intermediate level C++ programmer that has mostly worked on C++03 style code. A+


Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED

By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED

Settings can be changed at any time from the Cookie Policy page.