Swap
Swapping is made simple in C++ using std::swap.
With the function std::swap
defined in the header <utility>
, you can easily swap two objects. The generic implementation in the C++ standard library internally uses the function std::move
.
Get hands-on with 1200+ tech skills courses.