From 9b7be934207ebb799c36c28af1e00e804c2d31cf Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 20 Feb 2022 14:43:27 -0800 Subject: [PATCH] Allow using bitfield's copy-assignment operator --- common/BitField.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/common/BitField.h b/common/BitField.h index 7564292..ee42cb7 100644 --- a/common/BitField.h +++ b/common/BitField.h @@ -131,13 +131,9 @@ public: // so that we can use this within unions constexpr BitField() = default; - // We explicitly delete the copy assignment operator here, because the - // default copy assignment would copy the full storage value, rather than - // just the bits relevant to this particular bit field. - // Ideally, we would just implement the copy assignment to copy only the - // relevant bits, but we're prevented from doing that because the savestate - // code expects that this class is trivially copyable. - BitField& operator=(const BitField&) = delete; + // Warning! This copies ALL storage bits, not just the bits represented by this bitfield. + // This exists so that unions can be copyable. + BitField& operator=(const BitField&) = default; BitField& operator=(T val) {