diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index b1e5b4f17e4..72057ee16d7 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -370,6 +370,16 @@ constexpr inline quint64 qNextPowerOfTwo(qint64 v) return qNextPowerOfTwo(quint64(v)); } +constexpr inline unsigned long qNextPowerOfTwo(unsigned long v) +{ + return qNextPowerOfTwo(QIntegerForSizeof::Unsigned(v)); +} + +constexpr inline unsigned long qNextPowerOfTwo(long v) +{ + return qNextPowerOfTwo(QIntegerForSizeof::Unsigned(v)); +} + QT_END_NAMESPACE #endif // QMATH_H diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index eedb594e265..b6a12a721e9 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -435,7 +435,7 @@ inline constexpr size_t bucketsForCapacity(size_t requestedCapacity) noexcept return SpanConstants::NEntries; if (requestedCapacity >= maxNumBuckets()) return maxNumBuckets(); - return qNextPowerOfTwo(QIntegerForSize::Unsigned(2 * requestedCapacity - 1)); + return qNextPowerOfTwo(2 * requestedCapacity - 1); } inline constexpr size_t bucketForHash(size_t nBuckets, size_t hash) noexcept {