From 7bdbf197ee424c83318faf4b59dbd265676326db Mon Sep 17 00:00:00 2001 From: David Major Date: Thu, 6 Aug 2020 20:40:37 +0000 Subject: [PATCH] Bug 1657455 - Give EnumSet an assignment operator r=sg Newer clangs complain that we explicitly defined a copy constructor but not a copy assignment. Differential Revision: https://phabricator.services.mozilla.com/D86061 --- mfbt/EnumSet.h | 8 ++++++++ mfbt/tests/TestEnumSet.cpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/mfbt/EnumSet.h b/mfbt/EnumSet.h index ae4364034e266..f635ec51ffbf9 100644 --- a/mfbt/EnumSet.h +++ b/mfbt/EnumSet.h @@ -50,8 +50,16 @@ class EnumSet { } } +#ifdef DEBUG constexpr EnumSet(const EnumSet& aEnumSet) : mBitField(aEnumSet.mBitField) {} + constexpr EnumSet& operator=(const EnumSet& aEnumSet) { + mBitField = aEnumSet.mBitField; + incVersion(); + return *this; + } +#endif + /** * Add an element */ diff --git a/mfbt/tests/TestEnumSet.cpp b/mfbt/tests/TestEnumSet.cpp index d330f0d4ef6eb..035c1fcfee9ac 100644 --- a/mfbt/tests/TestEnumSet.cpp +++ b/mfbt/tests/TestEnumSet.cpp @@ -7,6 +7,8 @@ #include "mozilla/EnumSet.h" #include "mozilla/Vector.h" +#include + using namespace mozilla; enum SeaBird { @@ -78,6 +80,8 @@ class EnumSetSuite { "EnumSet should be no bigger than the enum by default"); static_assert(sizeof(EnumSet) == sizeof(uint32_t), "EnumSet should be able to have its size overriden."); + static_assert(std::is_trivially_copyable_v>, + "EnumSet should be lightweight outside of debug."); #endif }