© Peter Van Weert and Marc Gregoire 2019
Peter Van Weert and Marc GregoireC++17 Standard Library Quick Referencehttps://doi.org/10.1007/978-1-4842-4923-9_2

2. General Utilities

Peter Van Weert1  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, we also introduce 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 afterward. 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 ...

Get C++17 Standard Library Quick Reference: A Pocket Guide to Data Structures, Algorithms, and Functions 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.