Merge pull request #4629 from FearlessTobi/bunnei-fooled-me

Port minor changes for BitField from yuzu
This commit is contained in:
Weiyi Wang 2019-02-25 10:22:44 -05:00 committed by GitHub
commit fdb5a8c2df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -125,7 +125,7 @@ private:
using StorageTypeWithEndian = typename AddEndian<StorageType, EndianTag>::type;
public:
BitField& operator=(const BitField&) = default;
constexpr BitField& operator=(const BitField&) = default;
/// Constants to allow limited introspection of fields if needed
static constexpr std::size_t position = Position;
@ -166,15 +166,15 @@ public:
// so that we can use this within unions
constexpr BitField() = default;
FORCE_INLINE operator T() const {
constexpr operator T() const {
return Value();
}
FORCE_INLINE void Assign(const T& value) {
constexpr void Assign(const T& value) {
storage = (static_cast<StorageType>(storage) & ~mask) | FormatValue(value);
}
FORCE_INLINE T Value() const {
constexpr T Value() const {
return ExtractValue(storage);
}
@ -191,12 +191,9 @@ 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_pod<T>::value, "Invalid base type");
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable in a BitField");
};
#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>
using BitFieldBE = BitField<Position, Bits, T, BETag>;