@@ -28,15 +28,15 @@ namespace llvm {
28
28
// / initialization.
29
29
template <unsigned NumBits>
30
30
class Bitset {
31
- typedef uintptr_t BitWord;
31
+ using BitWord = uintptr_t ;
32
32
33
- enum { BITWORD_SIZE = ( unsigned ) sizeof (BitWord) * CHAR_BIT } ;
33
+ static constexpr unsigned BitwordBits = sizeof (BitWord) * CHAR_BIT;
34
34
35
- static_assert (BITWORD_SIZE == 64 || BITWORD_SIZE == 32 ,
35
+ static_assert (BitwordBits == 64 || BitwordBits == 32 ,
36
36
" Unsupported word size" );
37
37
38
38
static constexpr unsigned NumWords =
39
- (NumBits + BITWORD_SIZE - 1 ) / BITWORD_SIZE ;
39
+ (NumBits + BitwordBits - 1 ) / BitwordBits ;
40
40
41
41
protected:
42
42
using StorageType = std::array<BitWord, NumWords>;
@@ -60,23 +60,23 @@ class Bitset {
60
60
}
61
61
62
62
constexpr Bitset &set (unsigned I) {
63
- Bits[I / BITWORD_SIZE ] |= BitWord (1 ) << (I % BITWORD_SIZE );
63
+ Bits[I / BitwordBits ] |= BitWord (1 ) << (I % BitwordBits );
64
64
return *this ;
65
65
}
66
66
67
67
constexpr Bitset &reset (unsigned I) {
68
- Bits[I / BITWORD_SIZE ] &= ~(BitWord (1 ) << (I % BITWORD_SIZE ));
68
+ Bits[I / BitwordBits ] &= ~(BitWord (1 ) << (I % BitwordBits ));
69
69
return *this ;
70
70
}
71
71
72
72
constexpr Bitset &flip (unsigned I) {
73
- Bits[I / BITWORD_SIZE ] ^= BitWord (1 ) << (I % BITWORD_SIZE );
73
+ Bits[I / BitwordBits ] ^= BitWord (1 ) << (I % BitwordBits );
74
74
return *this ;
75
75
}
76
76
77
77
constexpr bool operator [](unsigned I) const {
78
- BitWord Mask = BitWord (1 ) << (I % BITWORD_SIZE );
79
- return (Bits[I / BITWORD_SIZE ] & Mask) != 0 ;
78
+ BitWord Mask = BitWord (1 ) << (I % BitwordBits );
79
+ return (Bits[I / BitwordBits ] & Mask) != 0 ;
80
80
}
81
81
82
82
constexpr bool test (unsigned I) const { return (*this )[I]; }
0 commit comments