25template<
typename EnumClass_,
int Size_ = 32>
class OptionSet
30 OptionSet() =
default;
31 OptionSet(
const OptionSet& other) =
default;
32 OptionSet& operator=(
const OptionSet& other) =
default;
33 OptionSet(OptionSet&& other) =
default;
34 OptionSet& operator=(OptionSet&& other) =
default;
35 ~OptionSet() =
default;
37 OptionSet(
const std::initializer_list<EnumClass_>& options)
39 for (
const EnumClass_& opt : options)
41 bits[(std::size_t)opt] =
true;
45 OptionSet& operator+=(EnumClass_ opt)
47 bits[(std::size_t)opt] =
true;
51 OptionSet& operator+=(
const OptionSet<EnumClass_>& other)
53 this->bits |= other.bits;
57 OptionSet operator+(
const EnumClass_& other)
const
59 OptionSet<EnumClass_> result(*
this);
60 return result += other;
63 OptionSet& operator-=(EnumClass_ opt)
65 bits[(std::size_t)opt] =
false;
69 OptionSet operator-(
const EnumClass_& other)
const
71 OptionSet<EnumClass_> result(*
this);
72 return result -= other;
75 bool operator[](EnumClass_ opt)
const
77 return bits[(std::size_t)opt];
80 bool operator==(
const OptionSet<EnumClass_>& other)
const
82 return bits == other.bits;
85 bool operator!=(
const OptionSet<EnumClass_>& other)
const
87 return bits != other.bits;
102 std::bitset<Size_> bits;