Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions src/Base/Bitmask.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,45 @@ class Flags {
constexpr Flags<Enum> operator&(const Enum &f) const {
return i & f;
}
constexpr Flags<Enum> &operator^=(const Flags<Enum> &other) {
i ^= other.i;
return *this;
}
constexpr Flags<Enum> &operator^=(const Enum &f) {
i ^= f;
return *this;
}
constexpr Flags<Enum> operator^(const Flags<Enum> &other) const {
return i ^ other.i;
}
constexpr Flags<Enum> operator^(const Enum &f) const {
return i ^ f;
}
constexpr bool operator==(const Flags<Enum> &other) const {
return isEqual(other);
}
constexpr bool operator!=(const Flags<Enum> &other) const {
return !isEqual(other);
}
constexpr bool operator==(const Enum &f) const {
return i == f;
}
constexpr bool operator!=(const Enum &f) const {
return i != f;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary -- we target C++23, which will autogenerate operator!=.

constexpr Flags<Enum> operator~() const {
return ~i;
}

constexpr bool operator!() const {
return !i;
using u = typename std::underlying_type<Enum>::type;
return !static_cast<u>(i);
}

explicit operator bool() const {
constexpr explicit operator bool() const {
return toUnderlyingType() != 0;
}
typename std::underlying_type<Enum>::type toUnderlyingType() const {
constexpr typename std::underlying_type<Enum>::type toUnderlyingType() const {
return static_cast<typename std::underlying_type<Enum>::type>(i);
}
};
Expand Down
Loading