This video makes me cry: "Doc Rivers from the heart" |
C++ Move Semantics - The Complete Guide |
C++ Move Semantics - The Complete Guideby Nicolai M. Josuttis
This book was written
and published incrementally (step-by-step) at leanpub,
|
Move semantics, introduced with C++11, has become a hallmark of modern C++ programming. However, it also complicates the language in many ways. After several years of support for move semantics, experienced programmers still struggle with all the details. Even for trivial classes, style guides give conflicting or inappropriate advice on how to benefit from move semantics. 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 as a programmer, you can use move semantics correctly. The book is valuable for those who are just starting to learn about move semantics and is essential for those who are using it already. You will learn:
As usual for books by Nicolai
Josuttis, the focus lies on the application of the features described
in practice. Compelling examples and useful background information help
you to understand and improve code, from trivial classes up to generic
foundation libraries and frameworks. Nicolai M. Josuttis is well known in the programming community for his authoritative books and talks. For more than 20 years he is a member of the C++ Standard Committee. He is the (co-)author of several worldwide best-sellers, including
|
"I thought I understood
move semantics but I didn't really! I learned a lot in your book." "This is the book Ive
needed for a long time. "Sometimes I think I have a better grasp on entanglement and quantum teleportation than I do in some weird C++ move semantics. To paraphrase Feynman: If you think you understand C++ move semantics, you do not understand C++ move semantics. Read this book." Victor Ciura |
Nicolai M. Josuttis | ||
C++ Move Semantics- The Complete Guide | ||
ISBN-13: | 978-3-96730-900-3 | |
ISBN-10: | 3-96730-900-2 |
Basic Features of Move Semantics:
Motivation of move semantics
Performance benefits
Rvalue references
std::move()
std::move() for members and member functions
Self-move
Overload resolution with move semantics
Value categories and xvalues
decltype with expressions
Enabling copy semantics only
Rule of five or three
How to initialize members with move semantics
Overloading on reference qualifiers
The return type of getters
Move semantics in polymorphic class hierarchies
const rvalue references (const&&)
Using noexcept
Dealing with moved-from states (invalid objects and broken invariants)
Move Semantics in Generic Code:
Universal/forwarding references
Perfect forwarding
std::forward<>()
Constructors with universal references
Perfect passing
auto&&
Universal references as non-forwarding references
Universal references of concrete types
Generic raw rvalue references
Perfect returning
decltype(auto)
Move semantics in lambdas
Move semantics in range-based for loops
Move Semantics in the C++ Standard Library :
Move-only types
- I/O streams
- Threads
- Unique Pointers
- When Scott Meyers and Herb Sutter contradict
Moving algorithms
Move semantics with removing algorithms
Move iterators
Move semantics for strings
Move semantics for containers (especially std::vectors and std::arrays)
Move semantics for std::shared_ptr<>
Move semantics for std::pair<>
- std::make_pair() and std::decay<>
Move semantics for std::optional<>
Note that you can also book
inhouse trainings about
all topics of Modern C++ and C++17
(both the language and its standard library) .