diff options
Diffstat (limited to 'chilbert/detail/operations.hpp')
-rw-r--r-- | chilbert/detail/operations.hpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/chilbert/detail/operations.hpp b/chilbert/detail/operations.hpp index 94635b4..1c6b8bf 100644 --- a/chilbert/detail/operations.hpp +++ b/chilbert/detail/operations.hpp @@ -157,7 +157,8 @@ template <typename T> std::enable_if_t<std::is_integral<T>::value> gray_code_inv(T& value) { - for (T shift = 1; shift < sizeof(T) * CHAR_BIT; shift <<= 1) { + constexpr T shift_end = sizeof(T) * CHAR_BIT; + for (T shift = 1; shift < shift_end; shift <<= 1) { value ^= (value >> shift); } } |