mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-25 17:04:04 +00:00
common/bit_field: Make BitField trivially copyable
This makes the class much more flexible and doesn't make performing copies with classes that contain a bitfield member a pain. Given BitField instances are only intended to be used within unions, the fact the full storage value would be copied isn't a big concern (only sizeof(union_type) would be copied anyways). While we're at it, provide defaulted move constructors for consistency.
This commit is contained in:
parent
1fbda5518e
commit
c47c24bbd2
1 changed files with 7 additions and 5 deletions
|
@ -125,8 +125,6 @@ private:
|
||||||
using StorageTypeWithEndian = typename AddEndian<StorageType, EndianTag>::type;
|
using StorageTypeWithEndian = typename AddEndian<StorageType, EndianTag>::type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
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;
|
||||||
static constexpr std::size_t bits = Bits;
|
static constexpr std::size_t bits = Bits;
|
||||||
|
@ -162,9 +160,13 @@ public:
|
||||||
BitField(T val) = delete;
|
BitField(T val) = delete;
|
||||||
BitField& operator=(T val) = delete;
|
BitField& operator=(T val) = delete;
|
||||||
|
|
||||||
// Force default constructor to be created
|
constexpr BitField() noexcept = default;
|
||||||
// so that we can use this within unions
|
|
||||||
constexpr BitField() = default;
|
constexpr BitField(const BitField&) noexcept = default;
|
||||||
|
constexpr BitField& operator=(const BitField&) noexcept = default;
|
||||||
|
|
||||||
|
constexpr BitField(BitField&&) noexcept = default;
|
||||||
|
constexpr BitField& operator=(BitField&&) noexcept = default;
|
||||||
|
|
||||||
constexpr operator T() const {
|
constexpr operator T() const {
|
||||||
return Value();
|
return Value();
|
||||||
|
|
Loading…
Reference in a new issue