diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/albit.h | 5 | ||||
-rw-r--r-- | common/opthelpers.h | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/common/albit.h b/common/albit.h index c54bb31a..2c83ca08 100644 --- a/common/albit.h +++ b/common/albit.h @@ -5,6 +5,7 @@ #include <type_traits> #if !defined(__GNUC__) && (defined(_WIN32) || defined(_WIN64)) #include <intrin.h> +#include "opthelpers.h" #endif namespace al { @@ -104,7 +105,7 @@ inline std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value int> countr_zero(T v) { unsigned long idx{std::numeric_limits<T>::digits}; - if /*constexpr*/(std::numeric_limits<T>::digits <= 32) + if_constexpr(std::numeric_limits<T>::digits <= 32) _BitScanForward(&idx, static_cast<uint32_t>(v)); else // std::numeric_limits<T>::digits > 32 _BitScanForward64(&idx, v); @@ -118,7 +119,7 @@ inline std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value int> countr_zero(T v) { unsigned long idx{std::numeric_limits<T>::digits}; - if /*constexpr*/(std::numeric_limits<T>::digits <= 32) + if_constexpr(std::numeric_limits<T>::digits <= 32) _BitScanForward(&idx, static_cast<uint32_t>(v)); else if(!_BitScanForward(&idx, static_cast<uint32_t>(v))) { diff --git a/common/opthelpers.h b/common/opthelpers.h index 8f16fd3f..df0be2f5 100644 --- a/common/opthelpers.h +++ b/common/opthelpers.h @@ -36,4 +36,10 @@ #define ASSUME(x) ((void)0) #endif +#if __cplusplus >= 201709L || defined(__cpp_if_constexpr) +#define if_constexpr if constexpr +#else +#define if_constexpr if +#endif + #endif /* OPTHELPERS_H */ |