Skip to Content
Advanced C++ Programming Cookbook
book

Advanced C++ Programming Cookbook

by Dr. Rian Quinn
January 2020
Intermediate to advanced
454 pages
11h 25m
English
Packt Publishing
Content preview from Advanced C++ Programming Cookbook

How it works...

In this recipe, we will learn why a const&& constructor or operator doesn't make sense and will result in unexpected behavior. A move transfers resources, which is why it is marked as non-const. This is because a transfer assumes that both instances are written to (one instance receives the resource while the other has the resource taken away). A copy creates resources, which is why they are not always marked as noexcept (creating resources absolutely could throw) and they are marked const (because the original instance is being copied, not modified). A const&& constructor is claiming to be a move that doesn't transfer, which must be a copy (if you are not writing to the original instance, you are not moving—you are copying), ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern C++ Programming Cookbook

Modern C++ Programming Cookbook

Marius Bancila

Publisher Resources

ISBN: 9781838559915Supplemental Content