Notebook C++: About Move Semantics
$8.99
Minimum price
$12.99
Suggested price

Notebook C++: About Move Semantics

About the Book

The idea of the Notebook C++ series is to share some tips and tricks about various C++ elements. All books in this series are short and small, one for each major topic. Such that the paperback version can be carried around easily.

About Move Semantics

This part of the series is all about move semantics. I will introduce the feature to you in an unconventional but easy-to-understand way. Move semantics are nothing special, after all.

We'll start looking at what move semantics is, how it works, and why we should stay away from std::move most of the time. We establish some rules about when to use std::move when std::forward. You learn about why not to move return values or temporary objects. Do you want the best speed from your custom data type and the STL? No problem, you will learn what your class must look like to achieve this.

In the end, you also learn about features not seen that often, such as reference qualifiers, how they work, why they are there, and when to use them.

All in all, after having read this book, you have a solid understanding of move semantics.

About the Author

Andreas Fertig
Andreas Fertig

Andreas Fertig, CEO of Unique Code GmbH, is an experienced trainer and lecturer for C++ for standards 11 to 23.

Andreas is involved in the C++ standardization committee, in which the new standards are developed. At international conferences, he presents how code can be written better. He publishes specialist articles, e.g., for iX magazine, and has published several textbooks on C++.

With C++ Insights (cppinsights.io), Andreas has created an internationally recognized tool that enables users to look behind the scenes of C++ and thus to understand constructs even better.

Before working as a trainer and consultant, he worked for Philips Medizin Systeme GmbH for ten years as a C++ software developer and architect focusing on embedded systems.

His web presence is andreasfertig.com.

Table of Contents

  • Notes by Standard at a Glance
    • Notes belonging to C++11
    • Notes belonging to C++17
    • Notes belonging to C++20
  • 2 Move Semantics
    • Note 1 : Understand the type of move used in C++
    • Note 2 : Move is nothing special
    • Note 3 : Move vs. copy
    • Note 4 : Move is a partial swap
    • Note 5 : std::move doesn't move
    • Note 6 : Understand the value categories
    • Note 7 : Make your rvalue parameters modifiable
    • Note 8 : Only classes with dynamic memory profit from move semantics
    • Note 9 : A moved-from object isn't special
    • Note 10 : Never use std::move on a return value
    • Note 11 : Remember to forward the move to all the base classes
    • Note 12 : Never use std::move on a temporary
    • Note 13 : When is it a forwarding reference
    • Note 14 : When to use std::forward
    • Note 15 : Your custom class and the STL
    • Note 16 : Known when you lose a special member
    • Note 17 : Even with a defaulted destructor, you lose the move operations
    • Note 18 : Be aware of std::initializer_list
    • Note 19 : Test for noexcept move
    • Note 20 : Use ref-qualifiers for more efficiency
    • Note 21 : Use ref-qualifiers on assignment operators
    • Note 22 : Understand user-declared and user-defined
    • Note 23 : Implicit move
    • Note 24 : Move semantics checklist
  • Acronyms
  • Bibliography
  • Index

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub