std::shift_left,std::shift_right (3)  Linux Manuals
std::shift_left,std::shift_right: std::shift_left,std::shift_right
NAME
std::shift_left,std::shift_right  std::shift_left,std::shift_right
Synopsis
Defined in header <algorithm>
template< class ForwardIt >
constexpr ForwardIt shift_left( ForwardIt first, ForwardIt last, (1) (since C++20)
typename std::iterator_traits<ForwardIt>::difference_type n );
template< class ExecutionPolicy, class ForwardIt >
ForwardIt shift_left( ExecutionPolicy&& policy, ForwardIt first, ForwardIt last, (2) (since C++20)
typename std::iterator_traits<ForwardIt>::difference_type n );
template< class ForwardIt >
constexpr ForwardIt shift_right( ForwardIt first, ForwardIt last, (3) (since C++20)
typename std::iterator_traits<ForwardIt>::difference_type n );
template< class ExecutionPolicy, class ForwardIt >
ForwardIt shift_right( ExecutionPolicy&& policy, ForwardIt first, ForwardIt last, (4) (since C++20)
typename std::iterator_traits<ForwardIt>::difference_type n );
Shifts the elements in the range [first, last) by n positions.
1) Shifts the elements towards the beginning of the range. If n <= 0  n >= last  first, there are no effects. Otherwise, for every integer i in [0, last  first  n), moves the element originally at position first + n + i to position first + i. The moves are performed in increasing order of i starting from 0.
3) Shifts the elements towards the end of the range. If n <= 0  n >= last  first, there are no effects. Otherwise, for every integer i in [0, last  first  n), moves the element originally at position first + i to position first + n + i. If ForwardIt meets the LegacyBidirectionalIterator requirements, then the moves are performed in decreasing order of i starting from last  first  n  1.
2,4) Same as (1) and (3), respectively, but executed according to policy and the moves may be performed in any order. These overloads does not participate in overload resolution unless std::is_execution_policy_v<std::decay_t<ExecutionPolicy>> is true.
Elements that are in the original range but not the new range are left in a valid but unspecified state.
Parameters
first  the beginning of the original range
last  the end of the original range
n  the number of positions to shift
policy  the execution policy to use. See execution_policy for details.
Type requirements

ForwardIt must meet the requirements of LegacyForwardIterator.

ForwardIt must meet either the requirements of LegacyBidirectionalIterator or the requirements of ValueSwappable for overloads (34).

The type of dereferenced ForwardIt must meet the requirements of MoveAssignable.
Return value
12) The end of the resulting range. If n is positive and less than last  first, returns first + (last  first  n). Otherwise if n is positive, returns first. Otherwise, returns last.
34) The beginning of the resulting range. If n is positive and less than last  first, returns first + n. Otherwise if n is positive, returns last. Otherwise, returns first.
Complexity
12) At most std::distance(first, last)  n assignments.
34) At most std::distance(first, last)  n assignment or swaps.
Exceptions
The overloads with a template parameter named ExecutionPolicy report errors as follows:
* If execution of a function invoked as part of the algorithm throws an exception and ExecutionPolicy is one of the standard_policies, std::terminate is called. For any other ExecutionPolicy, the behavior is implementationdefined.
* If the algorithm fails to allocate memory, std::bad_alloc is thrown.
See also
move moves a range of elements to a new location
(C++11)
move_backward moves a range of elements to a new location in backwards order
(C++11)
rotate (function template)