Daily bit(e) of C++ | std::shift_left, std::shift_right
Daily bit(e) of C++ ♻️22, The two algorithms that shift all elements in a range to the left or right by the given offset: std::shift_left, std::shift_right.
The C++20 std::shift_left and std::shift_right algorithms move elements in the provided range by the specified offset.
Both algorithms internally move, meaning we can simulate these algorithms manually by calling the std::move algorithm with the appropriate source and offset destination. However, std::shift_left and std::shift_right make this process much less error-prone.
Both algorithms have parallel (C++20) and range (C++23) versions.