Compare commits

...

3 Commits

Author SHA1 Message Date
Yuriy Chernyshov
75d3e4d83d Fix compilation with standard libraries implementations which use raw pointers as iterators 2026-01-16 11:19:22 +01:00
sehe
9b64641093 Add missing friend declaration
Fixes issue #100
2025-12-22 12:21:01 +01:00
Gennaro Prota
54c841d585 Exercise subtraction between iterators in the unit tests
Reason: This was missing. And we forgot a friend declaration for the
corresponding operator-(), which will be added with the next commit.
2025-12-22 11:53:06 +01:00
3 changed files with 8 additions and 4 deletions

View File

@@ -1426,13 +1426,13 @@ template< typename Iterator >
class bit_iterator_base
{
public:
typedef typename Iterator::iterator_category iterator_category;
typedef typename std::iterator_traits< Iterator >::iterator_category iterator_category;
typedef bool value_type;
typedef std::ptrdiff_t difference_type;
typedef value_type * pointer;
typedef value_type & reference;
static constexpr int bits_per_block = std::numeric_limits< typename Iterator::value_type >::digits;
static constexpr int bits_per_block = std::numeric_limits< typename std::iterator_traits< Iterator >::value_type >::digits;
BOOST_DYNAMIC_BITSET_CONSTEXPR20 bit_iterator_base( Iterator block_iterator, int bit_index );
@@ -1440,11 +1440,13 @@ public:
friend BOOST_DYNAMIC_BITSET_CONSTEXPR20 bool operator==( const bit_iterator_base< Iter > & lhs, const bit_iterator_base< Iter > & rhs );
template< typename Iter >
friend BOOST_DYNAMIC_BITSET_CONSTEXPR20 bool operator<( const bit_iterator_base< Iter > & lhs, const bit_iterator_base< Iter > & rhs );
template< typename Iter >
friend BOOST_DYNAMIC_BITSET_CONSTEXPR20 difference_type operator-( const bit_iterator_base< Iter > & lhs, const bit_iterator_base< Iter > & rhs );
protected:
BOOST_DYNAMIC_BITSET_CONSTEXPR20 void increment();
BOOST_DYNAMIC_BITSET_CONSTEXPR20 void decrement();
BOOST_DYNAMIC_BITSET_CONSTEXPR20 void add( typename Iterator::difference_type n );
BOOST_DYNAMIC_BITSET_CONSTEXPR20 void add( typename std::iterator_traits< Iterator >::difference_type n );
Iterator m_block_iterator;
int m_bit_index = 0;

View File

@@ -185,7 +185,7 @@ bit_iterator_base< Iterator >::decrement()
template< typename Iterator >
BOOST_DYNAMIC_BITSET_CONSTEXPR20 void
bit_iterator_base< Iterator >::add( typename Iterator::difference_type n )
bit_iterator_base< Iterator >::add( typename std::iterator_traits< Iterator >::difference_type n )
{
typename Iterator::difference_type d = m_bit_index + n;
m_block_iterator += d / bits_per_block;

View File

@@ -248,6 +248,8 @@ struct bitset_test
BOOST_TEST( *( 1 + b.begin() ) == b[ 1 ] );
BOOST_TEST( *( b.end() - 1 ) == b[ b.size() - 1 ] );
}
BOOST_TEST( b.end() - b.begin() == static_cast< std::ptrdiff_t >( b.size() ) );
}
static void