std::iter_swap
The function `std::iter_swap` is a utility in the C++ Standard Library that swaps the values of two elements pointed to by iterators. It takes two iterators as arguments and exchanges the values they point to, without needing to know the underlying data structure. This function is particularly useful in algorithms that require element rearrangement.
`std::iter_swap` is part of the `<algorithm>` header and is often used in conjunction with other algorithms like `std::sort` or `std::reverse`. It provides a simple and efficient way to manipulate data in containers such as `std::vector` or `std::list` while maintaining the integrity of the original data types.