Fix wrong code (amend)

This commit is contained in:
Alexey Milovidov 2021-05-05 20:25:53 +03:00
parent 35aba776e5
commit 8940677bf2

View File

@ -1127,12 +1127,8 @@ constexpr integer<Bits, Signed>::operator T() const noexcept
using UnsignedT = std::make_unsigned_t<T>;
UnsignedT res{};
for (unsigned i = 0; i < _impl::item_count; ++i)
{
if constexpr (sizeof(T) > sizeof(base_type))
res <<= (sizeof(base_type) * 8);
res += items[i];
}
for (unsigned i = 0; i < _impl::item_count && i <= sizeof(T) / sizeof(base_type); ++i)
res += UnsignedT(items[i]) << (sizeof(base_type) * 8 * i);
return res;
}