C++ Move Semantics - The Complete Guide
C++ Move Semantics - The Complete Guide
$6.90
Minimum price
$17.90
Suggested price
C++ Move Semantics - The Complete Guide

This book is 90% complete

Last updated on 2020-07-07

About the Book

Move semantics, introduced with C++11, has become a hallmark of modern C++ programming. However, it also complicates the language in many ways. Even after several years of support of move semantics experienced programmers struggle with all the details of move semantics. And style guides still don't recommend the right consequences for programming even of trivial classes.

Time to explain all aspects of C++ move semantics in detail.

This book teaches C++ move semantics. Starting from the basic principles it motivates and explains all the corner cases of move semantics so that you as a programmer can use move semantics right. The book is valuable for those that are beginning to learn about move semantics and is essential for those that are using it already.

You will learn:

  • Motivation and terminology of move semantics
  • How and why you implicitly benefit from move semantics
  • How to explicitly benefit from move semantics
  • All traps and how to deal with them
  • All consequences for your programming style

As usual for books by Nicolai Josuttis, the focus lies on the application of the new features in practice. Compelling examples and useful background information help to understand and improve code from trivial classes up to generic foundation libraries and frameworks.

Buy early, pay less, free updates

Note that this book is published step-by-step. It started with 110 pages first published in January 2020. Since then the content grows with new chapters, examples, and caveats about the features of move semantics and I integrate all feedback I get for the pages already published.

Currently, the book is feature complete (all language features are described).

Only the use of move semantics in the C++ standard library and the final proof reading (yes, I am not a native English writer) is missing.

See www.cppmove.com for a detailed list of covered topics.

As written, once you bought it you will get all updates for free.

There is not errata yet, but I welcome all feedback to improve the current version.

Look at http://www.cppmove.com/feedback.html.

PDF versus Other Formats

I write the book in LaTeX and generate PDF from it (the way I wrote my other books). The other formats (epub, mobi, and online reading) come from the leanpub markdown interface, for which I generate the necessary input from LaTeX by script.

Thus, the PDF layout has a better quality than the other formats. For example, the syntax highlighting rules for the formats other than PDF have to get fixed as soon as possible and the index is missing yet. Leanpub and me are working on corresponding improvements.

I hope you enjoy and benefit.

Nico

#movetcg

About the Author

Nicolai M. Josuttis
Nicolai M. Josuttis

Nicolai Josuttis (http://www.josuttis.com) is an independent system architect, technical manager, author, consultant, and trainer being active in C++ standardization for 20 years. He designs mid-sized and large software systems for the telecommunications, traffic, finance, and manufacturing industries.

He is well known in the programming community because he not only speaks and writes with authority, being the (co-)author of the world-wide best sellers The C++ Standard Library, C++ Templates, and SOA in Practice, but is also an innovative presenter, having talked at various conferences and events.

Table of Contents

  •  
    • Preface
      • An Experiment
      • Versions of This Book
      • Acknowledgments
    • About This Book
      • What You Should Know Before Reading This Book
      • Overall Structure of the Book
      • How to Read This Book
      • The Way I Implement
      • The C++ Standards
      • Example Code and Additional Information
      • Feedback
  • Basic Features of Move Semantics
    • The Power of Move Semantics
      • Motivation for Move Semantics
      • Implementing Move Semantics
      • Copying as a Fallback
      • std::move() for const Objects
      • Summary
    • Core Features of Move Semantics
      • Rvalue References
      • std::move()
      • Overloading by Different References
      • Passing by Value
      • Summary
    • Move Semantics in Classes
      • Move Semantics in Ordinary Classes
      • Disabling Move Semantics
      • Implementing Special Copy/Move Member Functions
      • Rules for Special Member Functions
      • The Rule of Five or Three
      • Summary
    • How to Benefit from Move Semantics
      • Avoid Objects with Names
      • Avoid Unnecessary std::move()
      • Initialize Members with Move Semantics
      • Move Semantics in Class Hierarchies
      • Summary
    • Overloading on Reference Qualifiers
      • Return Type of Getters
      • Overloading on Qualifiers
      • When to Use Reference Qualifiers
      • Summary
    • Moved-from States in Detail
      • Required and Guaranteed States of Moved-from Objects
      • Destructible and Assignable
      • Dealing with Broken Invariants
      • Summary
    • Move Semantics and noexcept
      • Move Constructors with and without noexcept
      • Details of noexcept
      • When and Where to Use noexcept
      • Summary
    • Value Categories and Reference Binding
      • Value Categories
      • Impact of Values Categories When Binding to References
      • When Lvalues become Rvalues
      • When Rvalues become Lvalues
      • Checking Value Categories with decltype
      • Summary
  • Move Semantics in Generic Code
    • Perfect Forwarding
      • Motivation for Perfect Forwarding
      • Implementing Perfect Forwarding
      • Rvalue References versus Universal References
      • Overload Resolution with Universal Reverences
      • Overload Resolution with Universal Reverences
      • Summary
    • Tricky Details of Perfect Forwarding
      • Universal References as Non-Forwarding References
      • Universal or Ordinary Rvalue Reference?
      • Perfect Forwarding in Lambdas
      • How the Standard Specifies Perfect Forwarding
      • Nasty Details of Perfect Forwarding
      • Summary
    • Perfect Passing with auto&&
      • Default Perfect Passing
      • Universal References with auto&&
      • auto&& as Non-Forwarding Reference
      • Perfect Forwarding in Lambdas
      • Summary
    • Perfect Returning with decltype(auto)
      • Perfect Returning
      • decltype(auto)
      • Summary
  • Move Semantics in the C++ Standard Library
    • Move Semantics in Core Types of the C++ Standard Library
      • Move Semantics for Pairs
      • Move Semantics for Strings
      • Move Semantics for Containers
      • std::optional<>
      • Move Iterators
      • Summary
    • Move-Only Types
      • Move Semantics for Unique Pointers
      • Move Semantics for I/O Streams
      • Move Semantics for Threads
      • Summary
    • Glossary
      • C
      • F
      • G
      • H
      • I
      • L
      • N
      • P
      • R
      • S
      • T
      • U
      • V
      • X
  • Notes

Authors have earned$9,098,746writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

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

See full terms

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), EPUB (for phones and tablets) and MOBI (for 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. It really is that easy.

Learn more about writing on Leanpub