Merge pull request #11491 from lioncash/set

Common/BitSet: Mark initializer_list constructor as constexpr
This commit is contained in:
Admiral H. Curtiss 2023-01-25 12:15:43 +01:00 committed by GitHub
commit 70b2a6736b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -93,11 +93,10 @@ public:
int m_bit;
};
constexpr BitSet() : m_val(0) {}
constexpr BitSet() = default;
constexpr explicit BitSet(IntTy val) : m_val(val) {}
BitSet(std::initializer_list<int> init)
constexpr BitSet(std::initializer_list<int> init)
{
m_val = 0;
for (int bit : init)
m_val |= (IntTy)1 << bit;
}
@ -132,7 +131,7 @@ public:
constexpr unsigned int Count() const { return std::popcount(m_val); }
constexpr Iterator begin() const { return ++Iterator(m_val, 0); }
constexpr Iterator end() const { return Iterator(m_val, -1); }
IntTy m_val;
IntTy m_val{};
};
} // namespace Common