<xstd/bits/bit_algorithm/bit_rotate.hpp>¶
bit_rotate¶
As ranges::rotate in [alg.rotate], with:
- Constraints: As for
bit_reverse. - Preconditions:
middleis in[ranges::begin(r), ranges::end(r)], checked by anassert. - Effects: Position
itakes position (i+m) modN, form = middle - ranges::begin(r), so a whole turn is no turn. The blocks rotate by whole blocks, then a funnel shift moves the remaining bits across each boundary. - Returns:
{ranges::begin(r) + (ranges::end(r) - middle), ranges::end(r)}. - Complexity: O(
N/D), without allocating. - Remarks: It moves no proxy through the standard library, so it is exact over proxy references where libstdc++'s
ranges::rotatebefore version 16 is not (GCC PR 121913). Therotr(n)of P3103R2 isbit_rotate(v, v.begin() + n), and itsrotl(n)isbit_rotate(v, v.end() - n).