Core/Bitset: Fix value constructor

Former-commit-id: 9ed58dc40a513d32fac946d8876ac702713e279a
This commit is contained in:
Lynix 2016-05-06 19:15:15 +02:00
parent 5d2fa3ce98
commit 11c435aa7d
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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;
} }