citra-emu
/
citra
Archived
1
0
Fork 0

bit_field: Remove is_pod check, add is_trivially_copyable_v.

This commit is contained in:
bunnei 2018-04-17 18:00:18 -04:00 committed by fearlessTobi
parent e24c7a474c
commit f8b3617394
1 changed files with 3 additions and 6 deletions

View File

@ -166,11 +166,11 @@ public:
// so that we can use this within unions // so that we can use this within unions
constexpr BitField() = default; constexpr BitField() = default;
constexpr FORCE_INLINE operator T() const { constexpr operator T() const {
return Value(); return Value();
} }
constexpr FORCE_INLINE void Assign(const T& value) { constexpr void Assign(const T& value) {
storage = (static_cast<StorageType>(storage) & ~mask) | FormatValue(value); storage = (static_cast<StorageType>(storage) & ~mask) | FormatValue(value);
} }
@ -191,12 +191,9 @@ private:
static_assert(position < 8 * sizeof(T), "Invalid position"); static_assert(position < 8 * sizeof(T), "Invalid position");
static_assert(bits <= 8 * sizeof(T), "Invalid number of bits"); static_assert(bits <= 8 * sizeof(T), "Invalid number of bits");
static_assert(bits > 0, "Invalid number of bits"); static_assert(bits > 0, "Invalid number of bits");
static_assert(std::is_pod<T>::value, "Invalid base type"); static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable in a BitField");
}; };
#pragma pack() #pragma pack()
static_assert(std::is_trivially_copyable<BitField<0, 1, unsigned>>::value,
"BitField must be trivially copyable");
template <std::size_t Position, std::size_t Bits, typename T> template <std::size_t Position, std::size_t Bits, typename T>
using BitFieldBE = BitField<Position, Bits, T, BETag>; using BitFieldBE = BitField<Position, Bits, T, BETag>;