diff options
author | Lioncash <mathew1800@gmail.com> | 2019-11-13 20:41:24 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-11-15 13:09:30 +0100 |
commit | 14581e4a59cfe983cae397850a091d866eee045c (patch) | |
tree | ce5a3ec2f5c04971f7512496e9fef8a4461ae51f | |
parent | Merge pull request #3103 from lioncash/cfunc (diff) | |
download | yuzu-14581e4a59cfe983cae397850a091d866eee045c.tar yuzu-14581e4a59cfe983cae397850a091d866eee045c.tar.gz yuzu-14581e4a59cfe983cae397850a091d866eee045c.tar.bz2 yuzu-14581e4a59cfe983cae397850a091d866eee045c.tar.lz yuzu-14581e4a59cfe983cae397850a091d866eee045c.tar.xz yuzu-14581e4a59cfe983cae397850a091d866eee045c.tar.zst yuzu-14581e4a59cfe983cae397850a091d866eee045c.zip |
-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 fd2bbbd99..2dbe37839 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -135,7 +135,8 @@ public: /// Constants to allow limited introspection of fields if needed static constexpr std::size_t position = Position; 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 @@ -143,7 +144,7 @@ public: * the results together. */ static constexpr FORCE_INLINE StorageType FormatValue(const T& value) { - return ((StorageType)value << position) & mask; + return (static_cast<StorageType>(value) << position) & mask; } /** |