Search⌘ K
AI Features

Applying the && Modifier to Class Member Functions

Explore how to apply the && modifier to C++ class member functions to restrict their use to rvalue objects. Understand why using std::move can prevent compiler optimizations like return value optimization and learn best practices for returning objects efficiently.

We'll cover the following...

In addition to being applied to objects, we can also add the && modifier to a member function of a class, just as we can apply a const modifier to a member function. As with the const modifier, a member function that has the && ...