Applying the && Modifier to Class Member Functions

Learn how to apply the && modifier to class member functions and prevent them from being moved when copies are elided.

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 && modifier will only be considered by overload resolution if the object is an rvalue:

Get hands-on with 1200+ tech skills courses.