qmath: add qNextPowerOfTwo(unsigned long) - for size_t
This completes the triad uint/ulong/qulonglong, ensuring that one of them will be size_t and one of them will be uintptr_t (size_t and uintptr_t don't have to be the same type). The signeds ensure one of them will be ptrdiff_t too. Pick-to: 6.5 Change-Id: I9671dee8ceb64aa9b9cafffd17415a0bfcbd68b7 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
This commit is contained in:
parent
f7fd5eaf95
commit
85c69f023f
@ -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<long>::Unsigned(v));
|
||||
}
|
||||
|
||||
constexpr inline unsigned long qNextPowerOfTwo(long v)
|
||||
{
|
||||
return qNextPowerOfTwo(QIntegerForSizeof<long>::Unsigned(v));
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QMATH_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<sizeof(size_t)>::Unsigned(2 * requestedCapacity - 1));
|
||||
return qNextPowerOfTwo(2 * requestedCapacity - 1);
|
||||
}
|
||||
inline constexpr size_t bucketForHash(size_t nBuckets, size_t hash) noexcept
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user