diff options
Diffstat (limited to 'src/common/bit_field.h')
| -rw-r--r-- | src/common/bit_field.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 1f3ecf844..f64ebdaf6 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | #pragma once | 33 | #pragma once |
| 34 | 34 | ||
| 35 | #include <cstddef> | ||
| 35 | #include <limits> | 36 | #include <limits> |
| 36 | #include <type_traits> | 37 | #include <type_traits> |
| 37 | 38 | ||
| @@ -160,7 +161,7 @@ public: | |||
| 160 | if (std::numeric_limits<T>::is_signed) | 161 | if (std::numeric_limits<T>::is_signed) |
| 161 | { | 162 | { |
| 162 | std::size_t shift = 8 * sizeof(T)-bits; | 163 | std::size_t shift = 8 * sizeof(T)-bits; |
| 163 | return (T)(((storage & GetMask()) << (shift - position)) >> shift); | 164 | return (T)((storage << (shift - position)) >> shift); |
| 164 | } | 165 | } |
| 165 | else | 166 | else |
| 166 | { | 167 | { |
| @@ -188,7 +189,7 @@ private: | |||
| 188 | 189 | ||
| 189 | __forceinline StorageType GetMask() const | 190 | __forceinline StorageType GetMask() const |
| 190 | { | 191 | { |
| 191 | return ((~(StorageTypeU)0) >> (8 * sizeof(T)-bits)) << position; | 192 | return (((StorageTypeU)~0) >> (8 * sizeof(T)-bits)) << position; |
| 192 | } | 193 | } |
| 193 | 194 | ||
| 194 | StorageType storage; | 195 | StorageType storage; |