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 Bitset& bitset) = default;
explicit Bitset(const String& bits);
template<typename T> explicit Bitset(T value);
template<typename T> Bitset(T value);
Bitset(Bitset&& bitset) noexcept = default;
~Bitset() noexcept = default;

View File

@ -120,14 +120,14 @@ namespace Nz
{
if (sizeof(T) <= sizeof(Block))
{
m_bitCount = CountBits(value);
m_bitCount = std::numeric_limits<T>::digits;
m_blocks.push_back(value);
}
else
{
// 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;
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)
UnboundedSet(bitPos, true);
@ -838,7 +838,7 @@ namespace Nz
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;
}