Commit d97417b
committed
Fix EnumFlags compilation for large enums
The EnumFlags fails to compile when the underlying enum has 30 or more elements.
With exactly 32 elements the compilation error is the following:
note: shift count 32 >= width of type 'int' (32 bits)
static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value
With 30 or 31 elements the compilation error is:
note: value -2147483649 is outside the range of representable values of type 'int'
static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value
The solution consists in casting to unint64_t the first "1" in the MaxRep expression, such that the bit shifts are
performed on a 64-bit variable.1 parent f37a28b commit d97417b
1 file changed
+8
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
0 commit comments