Daily bit(e) of C++ | std::swap_ranges
Daily bit(e) of C++ #412, The algorithm for swapping the elements of two ranges piecewise: std::swap_ranges.
The std::swap_ranges algorithm does a piecewise swap of two ranges of elements.
Consequently, std::swap_ranges has linear complexity but allows for swapping heterogeneous ranges.
Additionally, when working with containers that dynamically allocate memory, a swap might not be a suitable choice, especially with custom allocators or memory resources.