mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MathsFunctions: Make countNumberOfBits constexpr
This commit is contained in:
parent
b70b7a309d
commit
21d87c02c2
1 changed files with 2 additions and 2 deletions
|
|
@ -548,7 +548,7 @@ inline int nextPowerOfTwo (int n) noexcept
|
|||
int findHighestSetBit (uint32 n) noexcept;
|
||||
|
||||
/** Returns the number of bits in a 32-bit integer. */
|
||||
inline int countNumberOfBits (uint32 n) noexcept
|
||||
constexpr int countNumberOfBits (uint32 n) noexcept
|
||||
{
|
||||
n -= ((n >> 1) & 0x55555555);
|
||||
n = (((n >> 2) & 0x33333333) + (n & 0x33333333));
|
||||
|
|
@ -559,7 +559,7 @@ inline int countNumberOfBits (uint32 n) noexcept
|
|||
}
|
||||
|
||||
/** Returns the number of bits in a 64-bit integer. */
|
||||
inline int countNumberOfBits (uint64 n) noexcept
|
||||
constexpr int countNumberOfBits (uint64 n) noexcept
|
||||
{
|
||||
return countNumberOfBits ((uint32) n) + countNumberOfBits ((uint32) (n >> 32));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue