In this chapter, we will learn some advanced C++ move semantics. We will first discuss the Big Five, which is an idiom that simply encourages programmers to explicitly define the destruction and move/copy semantics of a class. Next, we will learn how to define a move constructor and move assignment operator; the different combinations of move semantics (including move-only and non-copyable); non-movable classes; and how to implement these classes and why they are important.
This chapter will also discuss some common pitfalls such as why a const && move makes no sense, and how to overcome l-value versus r-value reference types. The recipes in this chapter are important because once you enable C++11 or higher, move semantics is enabled, which changes how C++ fundamentally handles classes in numerous situations. The recipes in this chapter provide...