Commit 43ac264f authored by Max Kellermann's avatar Max Kellermann

tag/Mask: add `noexcept`

parent cbaa98c1
...@@ -28,67 +28,67 @@ class TagMask { ...@@ -28,67 +28,67 @@ class TagMask {
typedef uint_least32_t mask_t; typedef uint_least32_t mask_t;
mask_t value; mask_t value;
explicit constexpr TagMask(uint_least32_t _value) explicit constexpr TagMask(uint_least32_t _value) noexcept
:value(_value) {} :value(_value) {}
public: public:
TagMask() = default; TagMask() = default;
constexpr TagMask(TagType tag) constexpr TagMask(TagType tag) noexcept
:value(mask_t(1) << mask_t(tag)) {} :value(mask_t(1) << mask_t(tag)) {}
static constexpr TagMask None() { static constexpr TagMask None() noexcept {
return TagMask(mask_t(0)); return TagMask(mask_t(0));
} }
static constexpr TagMask All() { static constexpr TagMask All() noexcept {
return ~None(); return ~None();
} }
constexpr TagMask operator~() const { constexpr TagMask operator~() const noexcept {
return TagMask(~value); return TagMask(~value);
} }
constexpr TagMask operator&(TagMask other) const { constexpr TagMask operator&(TagMask other) const noexcept {
return TagMask(value & other.value); return TagMask(value & other.value);
} }
constexpr TagMask operator|(TagMask other) const { constexpr TagMask operator|(TagMask other) const noexcept {
return TagMask(value | other.value); return TagMask(value | other.value);
} }
constexpr TagMask operator^(TagMask other) const { constexpr TagMask operator^(TagMask other) const noexcept {
return TagMask(value ^ other.value); return TagMask(value ^ other.value);
} }
TagMask &operator&=(TagMask other) { TagMask &operator&=(TagMask other) noexcept {
value &= other.value; value &= other.value;
return *this; return *this;
} }
TagMask &operator|=(TagMask other) { TagMask &operator|=(TagMask other) noexcept {
value |= other.value; value |= other.value;
return *this; return *this;
} }
TagMask &operator^=(TagMask other) { TagMask &operator^=(TagMask other) noexcept {
value ^= other.value; value ^= other.value;
return *this; return *this;
} }
constexpr bool TestAny() const { constexpr bool TestAny() const noexcept {
return value != 0; return value != 0;
} }
constexpr bool Test(TagType tag) const { constexpr bool Test(TagType tag) const noexcept {
return (*this & tag).TestAny(); return (*this & tag).TestAny();
} }
void Set(TagType tag) { void Set(TagType tag) noexcept {
*this |= tag; *this |= tag;
} }
void Unset(TagType tag) { void Unset(TagType tag) noexcept {
*this |= ~TagMask(tag); *this |= ~TagMask(tag);
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment