tag/Mask: add `noexcept`

This commit is contained in:
Max Kellermann 2019-11-05 10:56:20 +01:00
parent cbaa98c1a1
commit 43ac264f54
1 changed files with 15 additions and 15 deletions

View File

@ -28,67 +28,67 @@ class TagMask {
typedef uint_least32_t mask_t;
mask_t value;
explicit constexpr TagMask(uint_least32_t _value)
explicit constexpr TagMask(uint_least32_t _value) noexcept
:value(_value) {}
public:
TagMask() = default;
constexpr TagMask(TagType tag)
constexpr TagMask(TagType tag) noexcept
:value(mask_t(1) << mask_t(tag)) {}
static constexpr TagMask None() {
static constexpr TagMask None() noexcept {
return TagMask(mask_t(0));
}
static constexpr TagMask All() {
static constexpr TagMask All() noexcept {
return ~None();
}
constexpr TagMask operator~() const {
constexpr TagMask operator~() const noexcept {
return TagMask(~value);
}
constexpr TagMask operator&(TagMask other) const {
constexpr TagMask operator&(TagMask other) const noexcept {
return TagMask(value & other.value);
}
constexpr TagMask operator|(TagMask other) const {
constexpr TagMask operator|(TagMask other) const noexcept {
return TagMask(value | other.value);
}
constexpr TagMask operator^(TagMask other) const {
constexpr TagMask operator^(TagMask other) const noexcept {
return TagMask(value ^ other.value);
}
TagMask &operator&=(TagMask other) {
TagMask &operator&=(TagMask other) noexcept {
value &= other.value;
return *this;
}
TagMask &operator|=(TagMask other) {
TagMask &operator|=(TagMask other) noexcept {
value |= other.value;
return *this;
}
TagMask &operator^=(TagMask other) {
TagMask &operator^=(TagMask other) noexcept {
value ^= other.value;
return *this;
}
constexpr bool TestAny() const {
constexpr bool TestAny() const noexcept {
return value != 0;
}
constexpr bool Test(TagType tag) const {
constexpr bool Test(TagType tag) const noexcept {
return (*this & tag).TestAny();
}
void Set(TagType tag) {
void Set(TagType tag) noexcept {
*this |= tag;
}
void Unset(TagType tag) {
void Unset(TagType tag) noexcept {
*this |= ~TagMask(tag);
}
};