Merge pull request #4629 from FearlessTobi/bunnei-fooled-me
Port minor changes for BitField from yuzu
This commit is contained in:
commit
fdb5a8c2df
1 changed files with 5 additions and 8 deletions
|
@ -125,7 +125,7 @@ private:
|
||||||
using StorageTypeWithEndian = typename AddEndian<StorageType, EndianTag>::type;
|
using StorageTypeWithEndian = typename AddEndian<StorageType, EndianTag>::type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BitField& operator=(const BitField&) = default;
|
constexpr BitField& operator=(const BitField&) = default;
|
||||||
|
|
||||||
/// 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;
|
||||||
|
@ -166,15 +166,15 @@ public:
|
||||||
// so that we can use this within unions
|
// so that we can use this within unions
|
||||||
constexpr BitField() = default;
|
constexpr BitField() = default;
|
||||||
|
|
||||||
FORCE_INLINE operator T() const {
|
constexpr operator T() const {
|
||||||
return Value();
|
return Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE T Value() const {
|
constexpr T Value() const {
|
||||||
return ExtractValue(storage);
|
return ExtractValue(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>;
|
||||||
|
|
Loading…
Reference in a new issue