Merge pull request #12474 from Dentomologist/bitset_use_static_cast

BitSet: Use direct initialization instead of c-style casts
This commit is contained in:
Admiral H. Curtiss 2024-01-01 22:01:45 +01:00 committed by GitHub
commit 370daaf26c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -98,15 +98,15 @@ public:
constexpr BitSet(std::initializer_list<int> init)
{
for (int bit : init)
m_val |= (IntTy)1 << bit;
m_val |= IntTy{1} << bit;
}
constexpr static BitSet AllTrue(size_t count)
{
return BitSet(count == sizeof(IntTy) * 8 ? ~(IntTy)0 : (((IntTy)1 << count) - 1));
return BitSet(count == sizeof(IntTy) * 8 ? ~IntTy{0} : ((IntTy{1} << count) - 1));
}
Ref operator[](size_t bit) { return Ref(this, (IntTy)1 << bit); }
Ref operator[](size_t bit) { return Ref(this, IntTy{1} << bit); }
constexpr const Ref operator[](size_t bit) const { return (*const_cast<BitSet*>(this))[bit]; }
constexpr bool operator==(BitSet other) const { return m_val == other.m_val; }
constexpr bool operator!=(BitSet other) const { return m_val != other.m_val; }