diff --git a/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp b/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp index 0b26809..21e655d 100644 --- a/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp +++ b/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp @@ -32,13 +32,7 @@ class is_container { private: template< typename U > - static decltype( - std::declval< U >().resize( std::size_t{} ), - std::declval< U >()[ 0 ], - typename U::value_type(), - std::is_same< typename U::value_type, Block >{}, - std::true_type{} - ) test( int ); + static decltype( std::declval< U >().resize( std::size_t{} ), std::declval< U >()[ 0 ], typename U::value_type(), std::is_same< typename U::value_type, Block >{}, std::true_type{} ) test( int ); template< typename > static std::false_type test( ... ); @@ -71,8 +65,7 @@ public: typedef typename allocator_type_extractor_impl< AllocatorOrContainer, Block, - is_container< AllocatorOrContainer, Block >::value - >::type type; + is_container< AllocatorOrContainer, Block >::value >::type type; }; template< typename T, int amount, int width /* = default */ > @@ -101,8 +94,7 @@ struct value_to_type // template< typename T > typename T::size_type -vector_max_size_workaround( const T & v ) - noexcept +vector_max_size_workaround( const T & v ) noexcept { typedef typename T::allocator_type allocator_type; diff --git a/include/boost/dynamic_bitset/dynamic_bitset.hpp b/include/boost/dynamic_bitset/dynamic_bitset.hpp index bb480f6..64395fb 100644 --- a/include/boost/dynamic_bitset/dynamic_bitset.hpp +++ b/include/boost/dynamic_bitset/dynamic_bitset.hpp @@ -86,37 +86,36 @@ class dynamic_bitset public: //! The same type as `Block`. // ----------------------------------------------------------------------- - typedef Block block_type; + typedef Block block_type; //! The allocator used for all memory allocations. // ----------------------------------------------------------------------- typedef typename detail::dynamic_bitset_impl::allocator_type_extractor< AllocatorOrContainer, Block >::type - allocator_type; + allocator_type; //! An unsigned integral type that can represent the size of the //! bitset. See \ref size(). // ----------------------------------------------------------------------- - typedef std::size_t size_type; + typedef std::size_t size_type; //! Note: Made public to cope with failures from many GCC and //! Clang versions which seem to ignore the friend declarations //! of `bit_iterator` and `const_bit_iterator`. // ----------------------------------------------------------------------- typedef typename std::conditional< - detail::dynamic_bitset_impl::is_container< AllocatorOrContainer, Block >::value, - AllocatorOrContainer, - std::vector< Block, AllocatorOrContainer > - >::type buffer_type; + detail::dynamic_bitset_impl::is_container< AllocatorOrContainer, Block >::value, + AllocatorOrContainer, + std::vector< Block, AllocatorOrContainer > >::type buffer_type; //! The number of bits the type `Block` uses to represent //! values, excluding any padding bits. Numerically equal to //! `std::numeric_limits< Block >::digits`. // ----------------------------------------------------------------------- - static constexpr int bits_per_block = std::numeric_limits< Block >::digits; + static constexpr int bits_per_block = std::numeric_limits< Block >::digits; //! The maximum value of `size_type`. // ----------------------------------------------------------------------- - static constexpr size_type npos = static_cast< size_type >( -1 ); + static constexpr size_type npos = static_cast< size_type >( -1 ); //! A proxy class to simulate lvalues of bit type. //! @@ -279,17 +278,17 @@ public: //! container provides LegacyBidirectionalIterators, this is a //! BidirectionalIterator. // ----------------------------------------------------------------------- - typedef bit_iterator< dynamic_bitset > iterator; + typedef bit_iterator< dynamic_bitset > iterator; //! A read-only iterator into the bitset. //! //! \copydetails iterator // ----------------------------------------------------------------------- - typedef const_bit_iterator< dynamic_bitset > const_iterator; + typedef const_bit_iterator< dynamic_bitset > const_iterator; //! A reverse read/write reverse iterator into the bitset. // ----------------------------------------------------------------------- - typedef std::reverse_iterator< iterator > reverse_iterator; + typedef std::reverse_iterator< iterator > reverse_iterator; //! A reverse read-only iterator into the bitset. // ----------------------------------------------------------------------- @@ -377,7 +376,7 @@ public: //! \param alloc The allocator to use. // ----------------------------------------------------------------------- template< typename CharT, typename Traits, typename Alloc > - explicit dynamic_bitset( const std::basic_string< CharT, Traits, Alloc > & s, typename std::basic_string< CharT, Traits, Alloc >::size_type pos = 0, typename std::basic_string< CharT, Traits, Alloc >::size_type n = (std::basic_string::npos), size_type num_bits = npos, const allocator_type & alloc = allocator_type() ); + explicit dynamic_bitset( const std::basic_string< CharT, Traits, Alloc > & s, typename std::basic_string< CharT, Traits, Alloc >::size_type pos = 0, typename std::basic_string< CharT, Traits, Alloc >::size_type n = ( std::basic_string< CharT, Traits, Alloc >::npos ), size_type num_bits = npos, const allocator_type & alloc = allocator_type() ); //! Similar to the constructor from a `basic_string`, but takes //! a pointer to a C-style string (and doesn't take a `pos`). @@ -610,7 +609,7 @@ public: //! \par Throws //! Nothing. // ----------------------------------------------------------------------- - void swap( dynamic_bitset & b ) noexcept; + void swap( dynamic_bitset & b ) noexcept; //! Move constructor. //! @@ -642,7 +641,7 @@ public: //! //! \return A copy of the said allocator. // ----------------------------------------------------------------------- - allocator_type get_allocator() const; + allocator_type get_allocator() const; //! Changes the number of bits of the bitset to `num_bits`. //! @@ -655,14 +654,14 @@ public: //! \param num_bits The new size of the bitset. //! \param value The value to set any new bit to. // ----------------------------------------------------------------------- - void resize( size_type num_bits, bool value = false ); + void resize( size_type num_bits, bool value = false ); //! Clears the bitset, i.e. makes its size zero. //! //! \par Throws //! Nothing. // ----------------------------------------------------------------------- - void clear(); + void clear(); //! Increases the size of the bitset by one, and sets the value //! of the new most significant bit to `bit`. @@ -673,7 +672,7 @@ public: //! //! \param bit The value to set the most significant bit to. // ----------------------------------------------------------------------- - void push_back( bool bit ); + void push_back( bool bit ); //! Increases the size of the bitset by one, and sets the value //! of the new least significant bit to `bit`. @@ -684,7 +683,7 @@ public: //! //! \param bit The value to set the least significant bit to. // ----------------------------------------------------------------------- - void push_front( bool bit ); + void push_front( bool bit ); //! Decreases the size of the bitset by one, removing the most //! significant bit. @@ -692,7 +691,7 @@ public: //! \pre //! `! this->empty()`. // ----------------------------------------------------------------------- - void pop_back(); + void pop_back(); //! Decreases the size of the bitset by one, removing the least //! significant bit. @@ -700,7 +699,7 @@ public: //! \pre //! `! this->empty()`. // ----------------------------------------------------------------------- - void pop_front(); + void pop_front(); //! Appends the bits in `block` to this bitset (appends to the //! most significant end). This increases the size of the bitset @@ -710,7 +709,7 @@ public: //! //! \param block The block to append. // ----------------------------------------------------------------------- - void append( Block block ); + void append( Block block ); //! Appends a range of blocks to `*this`. //! @@ -1333,28 +1332,28 @@ public: private: static constexpr int ulong_width = std::numeric_limits< unsigned long >::digits; - dynamic_bitset & range_operation( size_type pos, size_type len, Block ( *partial_block_operation )( Block, size_type, size_type ), Block ( *full_block_operation )( Block ) ); - void m_zero_unused_bits(); - bool m_check_invariants() const; + dynamic_bitset & range_operation( size_type pos, size_type len, Block ( *partial_block_operation )( Block, size_type, size_type ), Block ( *full_block_operation )( Block ) ); + void m_zero_unused_bits(); + bool m_check_invariants() const; - static bool m_not_empty( Block x ); - static bool m_not_full( Block x ); - size_type m_do_find_from( size_type first_block, bool value ) const; + static bool m_not_empty( Block x ); + static bool m_not_full( Block x ); + size_type m_do_find_from( size_type first_block, bool value ) const; - int count_extra_bits() const noexcept; - static size_type block_index( size_type pos ) noexcept; - static int bit_index( size_type pos ) noexcept; - static Block bit_mask( size_type pos ) noexcept; - static Block bit_mask( size_type first, size_type last ) noexcept; - static Block set_block_bits( Block block, size_type first, size_type last, bool val ) noexcept; + int count_extra_bits() const noexcept; + static size_type block_index( size_type pos ) noexcept; + static int bit_index( size_type pos ) noexcept; + static Block bit_mask( size_type pos ) noexcept; + static Block bit_mask( size_type first, size_type last ) noexcept; + static Block set_block_bits( Block block, size_type first, size_type last, bool val ) noexcept; // Functions for operations on ranges - static Block set_block_partial( Block block, size_type first, size_type last ) noexcept; - static Block set_block_full( Block ) noexcept; - static Block reset_block_partial( Block block, size_type first, size_type last ) noexcept; - static Block reset_block_full( Block ) noexcept; - static Block flip_block_partial( Block block, size_type first, size_type last ) noexcept; - static Block flip_block_full( Block block ) noexcept; + static Block set_block_partial( Block block, size_type first, size_type last ) noexcept; + static Block set_block_full( Block ) noexcept; + static Block reset_block_partial( Block block, size_type first, size_type last ) noexcept; + static Block reset_block_full( Block ) noexcept; + static Block flip_block_partial( Block block, size_type first, size_type last ) noexcept; + static Block flip_block_full( Block block ) noexcept; template< typename T > void dispatch_init( T num_bits, unsigned long value, detail::dynamic_bitset_impl::value_to_type< true > ); @@ -1413,8 +1412,8 @@ private: public: bit_appender( dynamic_bitset & r ); ~bit_appender(); - void do_append( bool value ); - size_type get_count() const; + void do_append( bool value ); + size_type get_count() const; }; }; @@ -1428,19 +1427,19 @@ public: 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 Iterator::value_type >::digits; bit_iterator_base( Iterator block_iterator, int bit_index ); template< typename Iter > friend bool operator==( const bit_iterator_base< Iter > & lhs, const bit_iterator_base< Iter > & rhs ); template< typename Iter > - friend bool operator< ( const bit_iterator_base< Iter > & lhs, const bit_iterator_base< Iter > & rhs ); + friend bool operator<( const bit_iterator_base< Iter > & lhs, const bit_iterator_base< Iter > & rhs ); protected: - void increment(); - void decrement(); - void add( typename Iterator::difference_type n ); + void increment(); + void decrement(); + void add( typename Iterator::difference_type n ); Iterator m_block_iterator; int m_bit_index = 0; @@ -1451,8 +1450,8 @@ class bit_iterator : public bit_iterator_base< typename DynamicBitset::buffer_type::iterator > { public: - typedef typename DynamicBitset::reference reference; - typedef reference * pointer; + typedef typename DynamicBitset::reference reference; + typedef reference * pointer; typedef typename bit_iterator_base< typename DynamicBitset::buffer_type::iterator >::difference_type difference_type; bit_iterator(); @@ -1473,9 +1472,9 @@ class const_bit_iterator : public bit_iterator_base< typename DynamicBitset::buffer_type::const_iterator > { public: - typedef bool reference; - typedef bool const_reference; - typedef const bool * pointer; + typedef bool reference; + typedef bool const_reference; + typedef const bool * pointer; typedef typename bit_iterator_base< typename DynamicBitset::buffer_type::const_iterator >::difference_type difference_type; const_bit_iterator( typename DynamicBitset::buffer_type::const_iterator block_iterator, int bit_index ); diff --git a/include/boost/dynamic_bitset/impl/dynamic_bitset.ipp b/include/boost/dynamic_bitset/impl/dynamic_bitset.ipp index f57e92c..1d91b6b 100644 --- a/include/boost/dynamic_bitset/impl/dynamic_bitset.ipp +++ b/include/boost/dynamic_bitset/impl/dynamic_bitset.ipp @@ -210,7 +210,7 @@ template< typename Iterator > bool operator!=( const bit_iterator_base< Iterator > & lhs, const bit_iterator_base< Iterator > & rhs ) { - return !( lhs == rhs ); + return ! ( lhs == rhs ); } template< typename Iterator > @@ -225,7 +225,7 @@ template< typename Iterator > bool operator<=( const bit_iterator_base< Iterator > & lhs, const bit_iterator_base< Iterator > & rhs ) { - return !( rhs < lhs ); + return ! ( rhs < lhs ); } template< typename Iterator > @@ -239,7 +239,7 @@ template< typename Iterator > bool operator>=( const bit_iterator_base< Iterator > & lhs, const bit_iterator_base< Iterator > & rhs ) { - return !( lhs < rhs ); + return ! ( lhs < rhs ); } template< typename Iterator > @@ -250,7 +250,7 @@ operator-( const bit_iterator_base< Iterator > & lhs, const bit_iterator_base< I + lhs.m_bit_index - rhs.m_bit_index; } -template< typename DynamicBitset> +template< typename DynamicBitset > bit_iterator< DynamicBitset >::bit_iterator() : bit_iterator_base< typename DynamicBitset::buffer_type::iterator >() { @@ -266,7 +266,7 @@ template< typename DynamicBitset > typename DynamicBitset::reference bit_iterator< DynamicBitset >::operator*() const { - return reference( *(this->m_block_iterator), this->m_bit_index ); + return reference( *( this->m_block_iterator ), this->m_bit_index ); } template< typename DynamicBitset > @@ -369,7 +369,7 @@ const_bit_iterator< DynamicBitset >::operator*() const return ( *( this->m_block_iterator ) & ( typename DynamicBitset::block_type( 1 ) << this->m_bit_index ) ) != 0; } -template< typename DynamicBitset > +template< typename DynamicBitset > const_bit_iterator< DynamicBitset > & const_bit_iterator< DynamicBitset >::const_bit_iterator::operator++() { @@ -421,8 +421,7 @@ const_bit_iterator< DynamicBitset >::operator-=( difference_type n ) template< typename DynamicBitset > const_bit_iterator< DynamicBitset > -operator+( const const_bit_iterator< DynamicBitset > & it, - typename const_bit_iterator< DynamicBitset >::difference_type n ) +operator+( const const_bit_iterator< DynamicBitset > & it, typename const_bit_iterator< DynamicBitset >::difference_type n ) { const_bit_iterator< DynamicBitset > temp = it; temp += n; @@ -431,16 +430,14 @@ operator+( const const_bit_iterator< DynamicBitset > & it, template< typename DynamicBitset > const_bit_iterator< DynamicBitset > -operator+( typename const_bit_iterator< DynamicBitset >::difference_type n, - const const_bit_iterator< DynamicBitset > & it ) +operator+( typename const_bit_iterator< DynamicBitset >::difference_type n, const const_bit_iterator< DynamicBitset > & it ) { return it + n; } template< typename DynamicBitset > const_bit_iterator< DynamicBitset > -operator-( const const_bit_iterator< DynamicBitset > & it, - typename const_bit_iterator< DynamicBitset >::difference_type n ) +operator-( const const_bit_iterator< DynamicBitset > & it, typename const_bit_iterator< DynamicBitset >::difference_type n ) { const_bit_iterator< DynamicBitset > temp = it; temp -= n; @@ -454,7 +451,6 @@ const_bit_iterator< DynamicBitset >::operator[]( difference_type n ) const return *( *this + n ); } - template< typename BlockIterator, typename B, typename A > void from_block_range( BlockIterator first, BlockIterator last, dynamic_bitset< B, A > & result ) @@ -500,9 +496,9 @@ dynamic_bitset< Block, AllocatorOrContainer >::dynamic_bitset( template< typename Block, typename AllocatorOrContainer > template< typename CharT > dynamic_bitset< Block, AllocatorOrContainer >::dynamic_bitset( - const CharT * s, - std::size_t n, - size_type num_bits, + const CharT * s, + std::size_t n, + size_type num_bits, const allocator_type & alloc ) : m_bits( alloc ), m_num_bits( 0 ) { @@ -527,9 +523,9 @@ dynamic_bitset< Block, AllocatorOrContainer >::dynamic_bitset( template< typename Block, typename AllocatorOrContainer > template< typename BlockInputIterator > dynamic_bitset< Block, AllocatorOrContainer >::dynamic_bitset( - BlockInputIterator first, - BlockInputIterator last, - const allocator_type & alloc ) + BlockInputIterator first, + BlockInputIterator last, + const allocator_type & alloc ) : m_bits( alloc ), m_num_bits( 0 ) { using boost::detail::dynamic_bitset_impl::is_numeric; @@ -791,7 +787,7 @@ dynamic_bitset< Block, AllocatorOrContainer >:: pop_front() { BOOST_ASSERT( ! empty() ); - + *this >>= 1; resize( size() - 1 ); } @@ -887,10 +883,10 @@ dynamic_bitset< Block, AllocatorOrContainer >::operator<<=( size_type n ) } // else if ( n > 0 ) { - const size_type last = num_blocks() - 1; // num_blocks() is >= 1 - const size_type div = n / bits_per_block; // div is <= last - const int r = bit_index( n ); - block_type * const b = &m_bits[ 0 ]; + const size_type last = num_blocks() - 1; // num_blocks() is >= 1 + const size_type div = n / bits_per_block; // div is <= last + const int r = bit_index( n ); + block_type * const b = &m_bits[ 0 ]; if ( r != 0 ) { const int rs = bits_per_block - r; @@ -930,10 +926,10 @@ dynamic_bitset< B, A >::operator>>=( size_type n ) } // else if ( n > 0 ) { - const size_type last = num_blocks() - 1; // num_blocks() is >= 1 - const size_type div = n / bits_per_block; // div is <= last - const int r = bit_index( n ); - block_type * const b = &m_bits[ 0 ]; + const size_type last = num_blocks() - 1; // num_blocks() is >= 1 + const size_type div = n / bits_per_block; // div is <= last + const int r = bit_index( n ); + block_type * const b = &m_bits[ 0 ]; if ( r != 0 ) { const int ls = bits_per_block - r; @@ -985,8 +981,7 @@ dynamic_bitset< Block, AllocatorOrContainer >::set( size_type pos, size_type len { if ( val ) { return range_operation( pos, len, set_block_partial, set_block_full ); - } - else { + } else { return range_operation( pos, len, reset_block_partial, reset_block_full ); } } @@ -999,8 +994,7 @@ dynamic_bitset< Block, AllocatorOrContainer >::set( size_type pos, bool val ) if ( val ) { m_bits[ block_index( pos ) ] |= bit_mask( pos ); - } - else { + } else { reset( pos ); } @@ -1112,9 +1106,9 @@ template< typename Block, typename AllocatorOrContainer > bool dynamic_bitset< Block, AllocatorOrContainer >::all() const { - const int extra_bits = count_extra_bits(); - const block_type all_ones = Block( -1 ); - const size_type num_normal_blocks = num_blocks() - ( extra_bits != 0 ? 1 : 0 ); + const int extra_bits = count_extra_bits(); + const block_type all_ones = Block( -1 ); + const size_type num_normal_blocks = num_blocks() - ( extra_bits != 0 ? 1 : 0 ); for ( size_type i = 0; i < num_normal_blocks; ++i ) { if ( m_bits[ i ] != all_ones ) { @@ -1352,8 +1346,8 @@ bool dynamic_bitset< Block, AllocatorOrContainer >::intersects( const dynamic_bitset & b ) const { const size_type common_blocks = num_blocks() < b.num_blocks() - ? num_blocks() - : b.num_blocks(); + ? num_blocks() + : b.num_blocks(); for ( size_type i = 0; i < common_blocks; ++i ) { if ( m_bits[ i ] & b.m_bits[ i ] ) { @@ -1372,18 +1366,15 @@ template< typename Block, typename AllocatorOrContainer > typename dynamic_bitset< Block, AllocatorOrContainer >::size_type dynamic_bitset< Block, AllocatorOrContainer >::m_do_find_from( size_type first_block, bool value ) const { - size_type i = std::distance( m_bits.begin(), std::find_if( m_bits.begin() + first_block, m_bits.end(), - value - ? m_not_empty - : m_not_full ) ); + size_type i = std::distance( m_bits.begin(), std::find_if( m_bits.begin() + first_block, m_bits.end(), value ? m_not_empty : m_not_full ) ); if ( i >= num_blocks() ) { return npos; // not found } const Block b = value - ? m_bits[ i ] - : m_bits[ i ] ^ Block( -1 ); + ? m_bits[ i ] + : m_bits[ i ] ^ Block( -1 ); return i * bits_per_block + static_cast< size_type >( detail::lowest_bit( b ) ); } @@ -1396,13 +1387,13 @@ dynamic_bitset< Block, AllocatorOrContainer >::find_first( size_type pos ) const return npos; } - const size_type blk = block_index( pos ); - const int ind = bit_index( pos ); + const size_type blk = block_index( pos ); + const int ind = bit_index( pos ); // shift bits upto one immediately after current - const Block fore = m_bits[ blk ] >> ind; + const Block fore = m_bits[ blk ] >> ind; - const bool found = m_not_empty( fore ); + const bool found = m_not_empty( fore ); return found ? pos + static_cast< size_type >( detail::lowest_bit( fore ) ) : m_do_find_from( blk + 1, true ); } @@ -1415,23 +1406,23 @@ dynamic_bitset< Block, AllocatorOrContainer >::find_first_off( size_type pos ) c return npos; } - const size_type blk = block_index( pos ); - const int ind = bit_index( pos ); - const Block fore = m_bits[ blk ] >> ind; - bool found = false; - int lowest_off_bit_pos = -1; + const size_type blk = block_index( pos ); + const int ind = bit_index( pos ); + const Block fore = m_bits[ blk ] >> ind; + bool found = false; + int lowest_off_bit_pos = -1; if ( m_not_full( fore ) ) { lowest_off_bit_pos = detail::lowest_bit( fore ^ Block( -1 ) ); // don't consider a zero introduced by m_bits[ blk ] >> ind as found - found = lowest_off_bit_pos <= ( bits_per_block - 1 - ind ); + found = lowest_off_bit_pos <= ( bits_per_block - 1 - ind ); } - + const size_type zero_pos = found - ? pos + lowest_off_bit_pos - : m_do_find_from( blk + 1, false ); + ? pos + lowest_off_bit_pos + : m_do_find_from( blk + 1, false ); return zero_pos >= size() - ? npos - : zero_pos; + ? npos + : zero_pos; } template< typename Block, typename AllocatorOrContainer > @@ -1449,8 +1440,8 @@ typename dynamic_bitset< Block, AllocatorOrContainer >::size_type dynamic_bitset< Block, AllocatorOrContainer >::find_next_off( size_type pos ) const { return pos == npos - ? npos - : find_first_off( pos + 1 ); + ? npos + : find_first_off( pos + 1 ); } //----------------------------------------------------------------------------- @@ -1477,8 +1468,8 @@ operator<( const dynamic_bitset< Block, AllocatorOrContainer > & a, const dynami { typedef BOOST_DEDUCED_TYPENAME dynamic_bitset< Block, AllocatorOrContainer >::size_type size_type; - size_type asize( a.size() ); - size_type bsize( b.size() ); + size_type asize( a.size() ); + size_type bsize( b.size() ); if ( ! bsize ) { return false; @@ -1489,8 +1480,7 @@ operator<( const dynamic_bitset< Block, AllocatorOrContainer > & a, const dynami size_type i = ii - 1; if ( a.m_bits[ i ] < b.m_bits[ i ] ) { return true; - } - else if ( a.m_bits[ i ] > b.m_bits[ i ] ) { + } else if ( a.m_bits[ i ] > b.m_bits[ i ] ) { return false; } } @@ -1503,8 +1493,7 @@ operator<( const dynamic_bitset< Block, AllocatorOrContainer > & a, const dynami size_type j = bsize - 1; if ( a[ i ] < b[ j ] ) { return true; - } - else if ( a[ i ] > b[ j ] ) { + } else if ( a[ i ] > b[ j ] ) { return false; } } @@ -1671,11 +1660,11 @@ operator>>( std::basic_istream< Ch, Tr > & is, dynamic_bitset< Block, Alloc > & typedef dynamic_bitset< Block, Alloc > bitset_type; typedef typename bitset_type::size_type size_type; - const streamsize w = is.width(); - const size_type limit = 0 < w && static_cast< size_type >( w ) < b.max_size() ? static_cast< size_type >( w ) : b.max_size(); + const streamsize w = is.width(); + const size_type limit = 0 < w && static_cast< size_type >( w ) < b.max_size() ? static_cast< size_type >( w ) : b.max_size(); bool exceptions_are_from_vector = false; - ios_base::iostate err = ios_base::goodbit; + ios_base::iostate err = ios_base::goodbit; typename basic_istream< Ch, Tr >::sentry cerberos( is ); // skips whitespaces if ( cerberos ) { // in accordance with prop. resol. of lib DR 303 [last checked 4 Feb 2004] @@ -1983,8 +1972,7 @@ dynamic_bitset< Block, AllocatorOrContainer >::set_block_bits( { if ( val ) { return block | bit_mask( first, last ); - } - else { + } else { return block & static_cast< Block >( ~bit_mask( first, last ) ); } } @@ -2077,7 +2065,7 @@ template< typename Block, typename AllocatorOrContainer > template< typename CharT, typename Traits > void dynamic_bitset< Block, AllocatorOrContainer >::init_from_string( - const CharT * s, // caution: not necessarily null-terminated + const CharT * s, // caution: not necessarily null-terminated std::size_t string_length, std::size_t pos, std::size_t n, @@ -2085,16 +2073,15 @@ dynamic_bitset< Block, AllocatorOrContainer >::init_from_string( { BOOST_ASSERT( pos <= string_length ); - const std::size_t rlen = (std::min)( n, string_length - pos ); const size_type sz = ( num_bits != npos ? num_bits : rlen ); m_bits.resize( calc_num_blocks( sz ) ); m_num_bits = sz; BOOST_DYNAMIC_BITSET_CTYPE_FACET( CharT, fac, std::locale() ); - const CharT one = BOOST_DYNAMIC_BITSET_WIDEN_CHAR( fac, '1' ); + const CharT one = BOOST_DYNAMIC_BITSET_WIDEN_CHAR( fac, '1' ); - const size_type m = num_bits < rlen ? num_bits : rlen; + const size_type m = num_bits < rlen ? num_bits : rlen; for ( std::size_t i = 0; i < m; ++i ) { const CharT c = s[ ( pos + m - 1 ) - i ]; @@ -2154,8 +2141,8 @@ void dynamic_bitset< Block, AllocatorOrContainer >::m_append( BlockInputIterator first, BlockInputIterator last, std::forward_iterator_tag ) { if ( first != last ) { - const int r = count_extra_bits(); - const std::size_t d = std::distance( first, last ); + const int r = count_extra_bits(); + const std::size_t d = std::distance( first, last ); m_bits.reserve( num_blocks() + d ); if ( r == 0 ) { do { @@ -2231,7 +2218,7 @@ template< typename Block, typename AllocatorOrContainer > struct hash< boost::dynamic_bitset< Block, AllocatorOrContainer > > { typedef boost::dynamic_bitset< Block, AllocatorOrContainer > argument_type; - typedef std::size_t result_type; + typedef std::size_t result_type; result_type operator()( const argument_type & a ) const noexcept {