forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #3106 from lioncash/bitfield

common/bit_field: Silence sign-conversion warnings
This commit is contained in:
Rodrigo Locatti 2019-11-15 18:49:20 -03:00 committed by GitHub
commit 3026aec9bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -135,7 +135,8 @@ public:
/// Constants to allow limited introspection of fields if needed /// Constants to allow limited introspection of fields if needed
static constexpr std::size_t position = Position; static constexpr std::size_t position = Position;
static constexpr std::size_t bits = Bits; static constexpr std::size_t bits = Bits;
static constexpr StorageType mask = (((StorageType)~0) >> (8 * sizeof(T) - bits)) << position; static constexpr StorageType mask = StorageType(
(std::numeric_limits<StorageType>::max() >> (8 * sizeof(T) - bits)) << position);
/** /**
* Formats a value by masking and shifting it according to the field parameters. A value * Formats a value by masking and shifting it according to the field parameters. A value
@ -143,7 +144,7 @@ public:
* the results together. * the results together.
*/ */
static constexpr FORCE_INLINE StorageType FormatValue(const T& value) { static constexpr FORCE_INLINE StorageType FormatValue(const T& value) {
return ((StorageType)value << position) & mask; return (static_cast<StorageType>(value) << position) & mask;
} }
/** /**