© Peter Van Weert and Marc Gregoire 2016
Peter Van Weert and Marc GregoireC++ Standard Library Quick Reference10.1007/978-1-4842-1876-1_2

2. General Utilities

Peter Van Weert and Marc Gregoire2
(1)
Kessel-Lo, Belgium
(2)
Meldert, Belgium
 

Moving, Forwarding, Swapping<utility>

This section explains move(), move_if_noexcept(), forward(), swap(), and exchange(). In passing, it also introduces the concepts of move semantics and perfect forwarding.

Moving

An object can be moved elsewhere (rather than copied) if its previous user no longer needs it. Moving the resources from one object to another can often be implemented far more efficiently than (deep) copying them. For a string object, for instance, moving is typically as simple as copying a char* pointer ...

Get C++ Standard Library Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.