From 6446fa7e484126b71d0bde2e6d45cff689ff9287 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 25 Jan 2023 04:11:14 -0500 Subject: [PATCH 1/2] Common/Bitset: Make initializer_list constructor constexpr This was able to be constexpr since C++14. --- Source/Core/Common/BitSet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/BitSet.h b/Source/Core/Common/BitSet.h index ad7df6afcd..e949b3a1e2 100644 --- a/Source/Core/Common/BitSet.h +++ b/Source/Core/Common/BitSet.h @@ -95,7 +95,7 @@ public: constexpr BitSet() : m_val(0) {} constexpr explicit BitSet(IntTy val) : m_val(val) {} - BitSet(std::initializer_list init) + constexpr BitSet(std::initializer_list init) { m_val = 0; for (int bit : init) From 0d93a31a3838226b4d14085f3512f2c39d4b1c6b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 25 Jan 2023 04:16:28 -0500 Subject: [PATCH 2/2] 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. --- Source/Core/Common/BitSet.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/BitSet.h b/Source/Core/Common/BitSet.h index e949b3a1e2..5d2c88294d 100644 --- a/Source/Core/Common/BitSet.h +++ b/Source/Core/Common/BitSet.h @@ -93,11 +93,10 @@ public: int m_bit; }; - constexpr BitSet() : m_val(0) {} + constexpr BitSet() = default; constexpr explicit BitSet(IntTy val) : m_val(val) {} constexpr BitSet(std::initializer_list 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