aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert/detail/operations.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-08-26 20:58:15 +0200
committerDavid Robillard <d@drobilla.net>2018-09-29 14:50:31 +0200
commit935807ad1a4214be21c65acc80a715e010dc7a92 (patch)
tree06f27c1eb0c04466dc0d4d02733136558e6ecfbf /chilbert/detail/operations.hpp
parent845ff6488070a91dd8c021608fc391b5a79d01b2 (diff)
downloadchilbert-935807ad1a4214be21c65acc80a715e010dc7a92.tar.gz
chilbert-935807ad1a4214be21c65acc80a715e010dc7a92.tar.bz2
chilbert-935807ad1a4214be21c65acc80a715e010dc7a92.zip
Explicitly factor out some const expressions
Diffstat (limited to 'chilbert/detail/operations.hpp')
-rw-r--r--chilbert/detail/operations.hpp3
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);
}
}