Common/BitSet: Zero initialize data member
Gets rid of the need to remember to initialize them in the constructor, except when overriding the default initializer.
This commit is contained in:
parent
6446fa7e48
commit
0d93a31a38
|
@ -93,11 +93,10 @@ public:
|
||||||
int m_bit;
|
int m_bit;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr BitSet() : m_val(0) {}
|
constexpr BitSet() = default;
|
||||||
constexpr explicit BitSet(IntTy val) : m_val(val) {}
|
constexpr explicit BitSet(IntTy val) : m_val(val) {}
|
||||||
constexpr BitSet(std::initializer_list<int> init)
|
constexpr BitSet(std::initializer_list<int> init)
|
||||||
{
|
{
|
||||||
m_val = 0;
|
|
||||||
for (int bit : init)
|
for (int bit : init)
|
||||||
m_val |= (IntTy)1 << bit;
|
m_val |= (IntTy)1 << bit;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +131,7 @@ public:
|
||||||
constexpr unsigned int Count() const { return std::popcount(m_val); }
|
constexpr unsigned int Count() const { return std::popcount(m_val); }
|
||||||
constexpr Iterator begin() const { return ++Iterator(m_val, 0); }
|
constexpr Iterator begin() const { return ++Iterator(m_val, 0); }
|
||||||
constexpr Iterator end() const { return Iterator(m_val, -1); }
|
constexpr Iterator end() const { return Iterator(m_val, -1); }
|
||||||
IntTy m_val;
|
IntTy m_val{};
|
||||||
};
|
};
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue