std::swap(a, b)
The function `std::swap(a, b)` is a standard library function in C++ that exchanges the values of two variables, `a` and `b`. When called, it takes the values stored in `a` and `b`, and swaps them so that `a` now holds the value of `b`, and vice versa. This is useful for rearranging data without needing a temporary variable.
`std::swap` is part of the `<algorithm>` header and can be used with any data type that supports assignment. It is often employed in algorithms that require sorting or rearranging elements, making it a fundamental tool in C++ programming.