Fix integer types in deflate_stream::bi_reverse

This commit is contained in:
Vinnie Falco
2017-06-22 08:56:46 -07:00
parent 246f55321c
commit b5c69ff7c7
2 changed files with 10 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
Version 65: Version 65:
* Enable narrowing warning on msvc cmake * Enable narrowing warning on msvc cmake
* Fix integer types in deflate_stream::bi_reverse
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -646,9 +646,10 @@ protected:
init(); init();
} }
template<class Unsigned>
static static
unsigned Unsigned
bi_reverse(unsigned code, int len); bi_reverse(Unsigned code, unsigned len);
template<class = void> template<class = void>
static static
@@ -742,12 +743,15 @@ protected:
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Reverse the first len bits of a code // Reverse the first len bits of a code
template<class Unsigned>
inline inline
unsigned Unsigned
deflate_stream:: deflate_stream::
bi_reverse(unsigned code, int len) bi_reverse(Unsigned code, unsigned len)
{ {
unsigned res = 0; BOOST_STATIC_ASSERT(std::is_unsigned<Unsigned>::value);
BOOST_ASSERT(len <= 8 * sizeof(unsigned));
Unsigned res = 0;
do do
{ {
res |= code & 1; res |= code & 1;