|
|
|
@ -54,33 +54,17 @@ template<class T, class U> class Set { |
|
|
|
/** @brief Create set from one value */ |
|
|
|
/** @brief Create set from one value */ |
|
|
|
inline constexpr Set(T value): value(static_cast<UnderlyingType>(value)) {} |
|
|
|
inline constexpr Set(T value): value(static_cast<UnderlyingType>(value)) {} |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Add value to the set */ |
|
|
|
|
|
|
|
inline constexpr Set<T, U> operator|(T other) const { |
|
|
|
|
|
|
|
return Set<T, U>(value | static_cast<UnderlyingType>(other)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Union of two sets */ |
|
|
|
/** @brief Union of two sets */ |
|
|
|
inline constexpr Set<T, U> operator|(Set<T, U> other) const { |
|
|
|
inline constexpr Set<T, U> operator|(Set<T, U> other) const { |
|
|
|
return Set<T, U>(value | other.value); |
|
|
|
return Set<T, U>(value | other.value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Add value to the set and assign */ |
|
|
|
|
|
|
|
inline Set<T, U>& operator|=(T other) { |
|
|
|
|
|
|
|
value |= static_cast<UnderlyingType>(other); |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Union two sets and assign */ |
|
|
|
/** @brief Union two sets and assign */ |
|
|
|
inline Set<T, U>& operator|=(Set<T, U> other) { |
|
|
|
inline Set<T, U>& operator|=(Set<T, U> other) { |
|
|
|
value |= other.value; |
|
|
|
value |= other.value; |
|
|
|
return *this; |
|
|
|
return *this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Check if given value is in the set */ |
|
|
|
|
|
|
|
inline constexpr T operator&(T other) const { |
|
|
|
|
|
|
|
return static_cast<T>(value & static_cast<UnderlyingType>(other)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Intersection of two sets */ |
|
|
|
/** @brief Intersection of two sets */ |
|
|
|
inline constexpr Set<T, U> operator&(Set<T, U> other) const { |
|
|
|
inline constexpr Set<T, U> operator&(Set<T, U> other) const { |
|
|
|
return Set<T, U>(value & other.value); |
|
|
|
return Set<T, U>(value & other.value); |
|
|
|
|