Iros
 
Loading...
Searching...
No Matches
rotl.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 RotlFunction {
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 rotl = detail::RotlFunction {};
25}
26
27namespace di {
28using bit::rotl;
29}
Definition bit_proxy_reference.h:5
Definition bit_proxy_reference.h:5
constexpr auto rotl
Definition rotl.h:24
Definition zstring_parser.h:9
constexpr auto operator()(T x, int s) const -> T
Definition rotl.h:10
Definition numeric_limits.h:7