std::rotr
Min standard notice:
Header: <bit>
Computes the result of bitwise right-rotating the value of x by s positions. This operation is also known as a right circular shift.
# Declarations
template< class T >
constexpr T rotr( T x, int s ) noexcept;
(since C++20)
# Parameters
x: value of unsigned integer types: number of positions to shift
# Return value
The result of bitwise right-rotating x by s positions.
# Notes
Feature-test macro Value Std Feature __cpp_lib_bitops 201907L (C++20) Bit operations
# Example
#include <bit>
#include <bitset>
#include <cstdint>
#include <iostream>
int main()
{
using bin = std::bitset<8>;
const std::uint8_t x{0b00011101};
std::cout << bin(x) << " <- x\n";
for (const int s : {0, 1, 9, -1, 2})
std::cout << bin(std::rotr(x, s)) << " <- rotr(x, " << s << ")\n";
}