Просмотр исходного кода

Revert "common/bit_field: Silence sign-conversion warnings"

Rodrigo Locatti 6 лет назад
Родитель
Сommit
8ed0d92e32
1 измененных файлов с 2 добавлено и 3 удалено
  1. 2 3
      src/common/bit_field.h

+ 2 - 3
src/common/bit_field.h

@@ -135,8 +135,7 @@ 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(
-        (std::numeric_limits<StorageType>::max() >> (8 * sizeof(T) - bits)) << position);
+    static constexpr StorageType mask = (((StorageType)~0) >> (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
@@ -144,7 +143,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 (static_cast<StorageType>(value) << position) & mask;
+        return ((StorageType)value << position) & mask;
     }
     }
 
 
     /**
     /**