Iros
 
Loading...
Searching...
No Matches
rotr.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/meta/language.h"
5
6namespace di::bit {
7namespace detail {
8 struct RotrFunction {
9 template<concepts::UnsignedInteger T>
10 constexpr auto operator()(T x, int s) const -> T {
11 constexpr auto N = math::NumericLimits<T>::digits;
12 int r = s % N;
13 if (r == 0) {
14 return x;
15 }
16 if (r > 0) {
17 return (x >> r) | (x << (N - r));
18 }
19 return (x << -r) | (x >> (N + r));
20 }
21 };
22}
23
24constexpr inline auto rotr = detail::RotrFunction {};
25}
26
27namespace di {
28using bit::rotr;
29}
Definition bit_proxy_reference.h:5
Definition bit_proxy_reference.h:5
constexpr auto rotr
Definition rotr.h:24
Definition zstring_parser.h:9
constexpr auto operator()(T x, int s) const -> T
Definition rotr.h:10
Definition numeric_limits.h:7