Skip to content

Commit

Permalink
Merge pull request #9 from LegionMammal978/fix-iterator
Browse files Browse the repository at this point in the history
Fix bit-position logic in bit_iterator
  • Loading branch information
ThePhD authored Jul 17, 2022
2 parents 22bf549 + 8f40746 commit 92db248
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/itsy/detail/bit_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ namespace ITSY_BITSY_SOURCE_NAMESPACE
}
__size_type __bit_advancement = __n % __binary_digits_v<__word_type>;
this->_M_pos += __bit_advancement;
if (this->_M_pos > __binary_digits_v<__word_type>)
if (this->_M_pos >= __binary_digits_v<__word_type>)
{
// put it back in the proper range
this->_M_pos -= __binary_digits_v<__word_type>;
Expand Down Expand Up @@ -939,7 +939,7 @@ namespace ITSY_BITSY_SOURCE_NAMESPACE
if (__bit_advancement > this->_M_pos)
{
// put it back in the proper range
this->_M_pos = __binary_digits_v<__word_type> - __bit_advancement;
this->_M_pos += __binary_digits_v<__word_type> - __bit_advancement;
// going forward by one extra since we
// overflow binary digit count
++__it_advancement;
Expand Down

0 comments on commit 92db248

Please sign in to comment.