@@ -17,7 +17,7 @@ namespace hud::windows
1717 */
1818 static constexpr u32 reverse_bytes (const u32 value) noexcept
1919 {
20- if ( hud::is_constant_evaluated ())
20+ if consteval
2121 {
2222 u32 tmp = ((value << 8 ) & 0xFF00FF00 ) | ((value >> 8 ) & 0xFF00FF );
2323 return (tmp << 16 ) | (tmp >> 16 );
@@ -36,7 +36,7 @@ namespace hud::windows
3636 */
3737 static constexpr u64 reverse_bytes (const u64 value) noexcept
3838 {
39- if ( hud::is_constant_evaluated ())
39+ if consteval
4040 {
4141 u64 tmp = value;
4242 tmp = ((tmp & 0x00000000FFFFFFFFull ) << 32 ) | ((tmp & 0xFFFFFFFF00000000ull ) >> 32 );
@@ -58,7 +58,7 @@ namespace hud::windows
5858 */
5959 static constexpr u32 rotate_left (const u32 value, const u32 shift) noexcept
6060 {
61- if ( hud::is_constant_evaluated ())
61+ if consteval
6262 {
6363 if (shift == 0 )
6464 {
@@ -80,7 +80,7 @@ namespace hud::windows
8080 */
8181 static constexpr u64 rotate_left (const u64 value, const u32 shift) noexcept
8282 {
83- if ( hud::is_constant_evaluated ())
83+ if consteval
8484 {
8585 if (shift == 0 )
8686 {
@@ -102,7 +102,7 @@ namespace hud::windows
102102 */
103103 static constexpr u32 rotate_right (const u32 value, const u32 shift) noexcept
104104 {
105- if ( hud::is_constant_evaluated ())
105+ if consteval
106106 {
107107 if (shift == 0 )
108108 {
@@ -124,7 +124,7 @@ namespace hud::windows
124124 */
125125 static constexpr u64 rotate_right (const u64 value, const u32 shift) noexcept
126126 {
127- if ( hud::is_constant_evaluated ())
127+ if consteval
128128 {
129129 if (shift == 0 )
130130 {
@@ -162,14 +162,19 @@ namespace hud::windows
162162#else
163163 if (value == 0 )
164164 return 32 ;
165- if (hud::is_constant_evaluated ())
165+ if consteval
166+ {
166167 return hud::common::bits::leading_zeros (value);
167- u32 result = 0 ;
168- if ( _BitScanReverse (( unsigned long *)&result, value))
168+ }
169+ else
169170 {
170- return 31 - result;
171+ u32 result = 0 ;
172+ if (_BitScanReverse ((unsigned long *)&result, value))
173+ {
174+ return 31 - result;
175+ }
176+ return 32 ;
171177 }
172- return 32 ;
173178#endif
174179 }
175180
@@ -181,27 +186,32 @@ namespace hud::windows
181186#else
182187 if (value == 0 )
183188 return 64 ;
184- if (hud::is_constant_evaluated ())
185- return hud::common::bits::leading_zeros (value);
186- #if defined(HD_TARGET_X64)
187- u32 result = 0 ;
188- if (_BitScanReverse64 ((unsigned long *)&result, value))
189- {
190- return 63 - result;
191- }
192- return 64 ;
193- #else
194- u32 result = 0 ;
195- if ((value >> 32 ) && _BitScanReverse ((unsigned long *)&result, static_cast <u32 >(value >> 32 )))
189+ if consteval
196190 {
197- return 31 - result ;
191+ return hud::common::bits::leading_zeros (value) ;
198192 }
199- if ( _BitScanReverse (( unsigned long *)&result, static_cast < u32 >(value)))
193+ else
200194 {
201- return 63 - result;
202- }
203- return 64 ;
195+ #if defined(HD_TARGET_X64)
196+ u32 result = 0 ;
197+ if (_BitScanReverse64 ((unsigned long *)&result, value))
198+ {
199+ return 63 - result;
200+ }
201+ return 64 ;
202+ #else
203+ u32 result = 0 ;
204+ if ((value >> 32 ) && _BitScanReverse ((unsigned long *)&result, static_cast <u32 >(value >> 32 )))
205+ {
206+ return 31 - result;
207+ }
208+ if (_BitScanReverse ((unsigned long *)&result, static_cast <u32 >(value)))
209+ {
210+ return 63 - result;
211+ }
212+ return 64 ;
204213 #endif
214+ }
205215#endif
206216 }
207217
@@ -222,11 +232,16 @@ namespace hud::windows
222232#else
223233 if (value == 0 )
224234 return 32 ;
225- if (hud::is_constant_evaluated ())
235+ if consteval
236+ {
226237 return hud::common::bits::trailing_zeros (value);
227- u32 result = 0 ;
228- _BitScanForward ((unsigned long *)&result, value);
229- return result;
238+ }
239+ else
240+ {
241+ u32 result = 0 ;
242+ _BitScanForward ((unsigned long *)&result, value);
243+ return result;
244+ }
230245#endif
231246 }
232247
@@ -237,22 +252,27 @@ namespace hud::windows
237252#else
238253 if (value == 0 )
239254 return 64 ;
240- if (hud::is_constant_evaluated ())
255+ if consteval
256+ {
241257 return hud::common::bits::trailing_zeros (value);
258+ }
259+ else
260+ {
242261 #if defined(HD_TARGET_X64)
243- u64 result = 0 ;
244- _BitScanForward64 ((unsigned long *)&result, value);
245- return result;
262+ u64 result = 0 ;
263+ _BitScanForward64 ((unsigned long *)&result, value);
264+ return result;
246265 #else
247- u32 result = 0 ;
248- if (static_cast <u32 >(value) == 0 )
249- {
250- _BitScanForward ((unsigned long *)&result, static_cast <u32 >(value >> 32 ));
251- return result + 32 ;
252- }
253- _BitScanForward ((unsigned long *)&result, static_cast <u32 >(value));
254- return result;
266+ u32 result = 0 ;
267+ if (static_cast <u32 >(value) == 0 )
268+ {
269+ _BitScanForward ((unsigned long *)&result, static_cast <u32 >(value >> 32 ));
270+ return result + 32 ;
271+ }
272+ _BitScanForward ((unsigned long *)&result, static_cast <u32 >(value));
273+ return result;
255274 #endif
275+ }
256276#endif
257277 }
258278 };
0 commit comments