Core/Bitset: Fix value constructor
Former-commit-id: 44cfe386a985a4b449527a9fab3d5da49e30117c
This commit is contained in:
parent
190462fd31
commit
e34c94343f
|
|
@ -31,7 +31,7 @@ namespace Nz
|
||||||
Bitset(const char* bits, unsigned int bitCount);
|
Bitset(const char* bits, unsigned int bitCount);
|
||||||
Bitset(const Bitset& bitset) = default;
|
Bitset(const Bitset& bitset) = default;
|
||||||
explicit Bitset(const String& bits);
|
explicit Bitset(const String& bits);
|
||||||
template<typename T> explicit Bitset(T value);
|
template<typename T> Bitset(T value);
|
||||||
Bitset(Bitset&& bitset) noexcept = default;
|
Bitset(Bitset&& bitset) noexcept = default;
|
||||||
~Bitset() noexcept = default;
|
~Bitset() noexcept = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,14 +120,14 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (sizeof(T) <= sizeof(Block))
|
if (sizeof(T) <= sizeof(Block))
|
||||||
{
|
{
|
||||||
m_bitCount = CountBits(value);
|
m_bitCount = std::numeric_limits<T>::digits;
|
||||||
m_blocks.push_back(value);
|
m_blocks.push_back(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Note: I was kinda tired when I wrote this, there's probably a much easier method than checking bits to write bits
|
// Note: I was kinda tired when I wrote this, there's probably a much easier method than checking bits to write bits
|
||||||
unsigned int bitPos = 0;
|
unsigned int bitPos = 0;
|
||||||
for (T bit = 1; bit < std::numeric_limits<T>::digits; bit <<= 1)
|
for (T bit = 1; bit < std::numeric_limits<T>::max(); bit <<= 1)
|
||||||
{
|
{
|
||||||
if (value & bit)
|
if (value & bit)
|
||||||
UnboundedSet(bitPos, true);
|
UnboundedSet(bitPos, true);
|
||||||
|
|
@ -838,7 +838,7 @@ namespace Nz
|
||||||
|
|
||||||
Block block = m_blocks[i];
|
Block block = m_blocks[i];
|
||||||
|
|
||||||
// Compute the position of LSB in the block (and adjustement of the position)
|
// Compute the position of LSB in the block (and adjustment of the position)
|
||||||
return IntegralLog2Pot(block & -block) + i*bitsPerBlock;
|
return IntegralLog2Pot(block & -block) + i*bitsPerBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue