From cd1d5786d998efdf18e9938db957f82331bab579 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 31 May 2014 19:04:35 +0200 Subject: 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. --- src/common/bit_field.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/bit_field.h b/src/common/bit_field.h index c28e722c8..52f0d8be6 100644 --- a/src/common/bit_field.h +++ b/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::value, "Invalid base type"); }; #pragma pack() -- cgit v1.2.3