Explorar o código

BitField: Add a static_assert.

Being able to store BitField within unions requires BitField to be of standard layout, which in turn is only given if the underlying type is also has standard layout.
Tony Wasserka %!s(int64=12) %!d(string=hai) anos
pai
achega
cd1d5786d9
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      src/common/bit_field.h

+ 1 - 0
src/common/bit_field.h

@@ -189,5 +189,6 @@ private:
     static_assert(position < 8 * sizeof(T), "Invalid position");
     static_assert(bits <= 8 * sizeof(T), "Invalid number of bits");
     static_assert(bits > 0, "Invalid number of bits");
+    static_assert(std::is_standard_layout<T>::value, "Invalid base type");
 };
 #pragma pack()