Skip to content

Commit

Permalink
Bug 1657455 - Give EnumSet an assignment operator r=sg
Browse files Browse the repository at this point in the history
Newer clangs complain that we explicitly defined a copy constructor but not a copy assignment.

Differential Revision: https://phabricator.services.mozilla.com/D86061
  • Loading branch information
David Major committed Aug 6, 2020
1 parent 852a191 commit 7bdbf19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mfbt/EnumSet.h
Expand Up @@ -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
*/
Expand Down
4 changes: 4 additions & 0 deletions mfbt/tests/TestEnumSet.cpp
Expand Up @@ -7,6 +7,8 @@
#include "mozilla/EnumSet.h"
#include "mozilla/Vector.h"

#include <type_traits>

using namespace mozilla;

enum SeaBird {
Expand Down Expand Up @@ -78,6 +80,8 @@ class EnumSetSuite {
"EnumSet should be no bigger than the enum by default");
static_assert(sizeof(EnumSet<SmallEnum, uint32_t>) == sizeof(uint32_t),
"EnumSet should be able to have its size overriden.");
static_assert(std::is_trivially_copyable_v<EnumSet<SmallEnum>>,
"EnumSet should be lightweight outside of debug.");
#endif
}

Expand Down

0 comments on commit 7bdbf19

Please sign in to comment.