bitflags: Be explicit in binary operators and such.

This allows having explicit + default constructor without build issues.
This commit is contained in:
Emilio Cobos Álvarez
2022-06-07 21:32:28 +02:00
parent 9855f90b65
commit 80da6045ec
3 changed files with 19 additions and 18 deletions
+4 -4
View File
@@ -14,24 +14,24 @@ struct StyleAlignFlags {
return !!bits;
}
constexpr StyleAlignFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
return StyleAlignFlags { static_cast<decltype(bits)>(~bits) };
}
constexpr StyleAlignFlags operator|(const StyleAlignFlags& other) const {
return {static_cast<decltype(bits)>(this->bits | other.bits)};
return StyleAlignFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
}
StyleAlignFlags& operator|=(const StyleAlignFlags& other) {
*this = (*this | other);
return *this;
}
constexpr StyleAlignFlags operator&(const StyleAlignFlags& other) const {
return {static_cast<decltype(bits)>(this->bits & other.bits)};
return StyleAlignFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
}
StyleAlignFlags& operator&=(const StyleAlignFlags& other) {
*this = (*this & other);
return *this;
}
constexpr StyleAlignFlags operator^(const StyleAlignFlags& other) const {
return {static_cast<decltype(bits)>(this->bits ^ other.bits)};
return StyleAlignFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
}
StyleAlignFlags& operator^=(const StyleAlignFlags& other) {
*this = (*this ^ other);
+12 -12
View File
@@ -14,24 +14,24 @@ struct AlignFlags {
return !!bits;
}
constexpr AlignFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
return AlignFlags { static_cast<decltype(bits)>(~bits) };
}
constexpr AlignFlags operator|(const AlignFlags& other) const {
return {static_cast<decltype(bits)>(this->bits | other.bits)};
return AlignFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
}
AlignFlags& operator|=(const AlignFlags& other) {
*this = (*this | other);
return *this;
}
constexpr AlignFlags operator&(const AlignFlags& other) const {
return {static_cast<decltype(bits)>(this->bits & other.bits)};
return AlignFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
}
AlignFlags& operator&=(const AlignFlags& other) {
*this = (*this & other);
return *this;
}
constexpr AlignFlags operator^(const AlignFlags& other) const {
return {static_cast<decltype(bits)>(this->bits ^ other.bits)};
return AlignFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
}
AlignFlags& operator^=(const AlignFlags& other) {
*this = (*this ^ other);
@@ -59,24 +59,24 @@ struct DebugFlags {
return !!bits;
}
constexpr DebugFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
return DebugFlags { static_cast<decltype(bits)>(~bits) };
}
constexpr DebugFlags operator|(const DebugFlags& other) const {
return {static_cast<decltype(bits)>(this->bits | other.bits)};
return DebugFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
}
DebugFlags& operator|=(const DebugFlags& other) {
*this = (*this | other);
return *this;
}
constexpr DebugFlags operator&(const DebugFlags& other) const {
return {static_cast<decltype(bits)>(this->bits & other.bits)};
return DebugFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
}
DebugFlags& operator&=(const DebugFlags& other) {
*this = (*this & other);
return *this;
}
constexpr DebugFlags operator^(const DebugFlags& other) const {
return {static_cast<decltype(bits)>(this->bits ^ other.bits)};
return DebugFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
}
DebugFlags& operator^=(const DebugFlags& other) {
*this = (*this ^ other);
@@ -93,24 +93,24 @@ struct LargeFlags {
return !!bits;
}
constexpr LargeFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
return LargeFlags { static_cast<decltype(bits)>(~bits) };
}
constexpr LargeFlags operator|(const LargeFlags& other) const {
return {static_cast<decltype(bits)>(this->bits | other.bits)};
return LargeFlags { static_cast<decltype(bits)>(this->bits | other.bits) };
}
LargeFlags& operator|=(const LargeFlags& other) {
*this = (*this | other);
return *this;
}
constexpr LargeFlags operator&(const LargeFlags& other) const {
return {static_cast<decltype(bits)>(this->bits & other.bits)};
return LargeFlags { static_cast<decltype(bits)>(this->bits & other.bits) };
}
LargeFlags& operator&=(const LargeFlags& other) {
*this = (*this & other);
return *this;
}
constexpr LargeFlags operator^(const LargeFlags& other) const {
return {static_cast<decltype(bits)>(this->bits ^ other.bits)};
return LargeFlags { static_cast<decltype(bits)>(this->bits ^ other.bits) };
}
LargeFlags& operator^=(const LargeFlags& other) {
*this = (*this ^ other);