Skip to content

Commit 2da0cd5

Browse files
committed
Always use braces with for-statements, as well
Reason: Consistency and safety. See: "Always use braces with if-statements".
1 parent 49a615d commit 2da0cd5

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

include/boost/dynamic_bitset/impl/dynamic_bitset.ipp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,9 @@ dynamic_bitset< Block, Allocator > &
398398
dynamic_bitset< Block, Allocator >::operator&=( const dynamic_bitset & rhs )
399399
{
400400
BOOST_ASSERT( size() == rhs.size() );
401-
for ( size_type i = 0; i < num_blocks(); ++i )
401+
for ( size_type i = 0; i < num_blocks(); ++i ) {
402402
m_bits[ i ] &= rhs.m_bits[ i ];
403+
}
403404
return *this;
404405
}
405406

@@ -408,8 +409,9 @@ dynamic_bitset< Block, Allocator > &
408409
dynamic_bitset< Block, Allocator >::operator|=( const dynamic_bitset & rhs )
409410
{
410411
BOOST_ASSERT( size() == rhs.size() );
411-
for ( size_type i = 0; i < num_blocks(); ++i )
412+
for ( size_type i = 0; i < num_blocks(); ++i ) {
412413
m_bits[ i ] |= rhs.m_bits[ i ];
414+
}
413415
// m_zero_unused_bits();
414416
return *this;
415417
}
@@ -419,8 +421,9 @@ dynamic_bitset< Block, Allocator > &
419421
dynamic_bitset< Block, Allocator >::operator^=( const dynamic_bitset & rhs )
420422
{
421423
BOOST_ASSERT( size() == rhs.size() );
422-
for ( size_type i = 0; i < this->num_blocks(); ++i )
424+
for ( size_type i = 0; i < this->num_blocks(); ++i ) {
423425
m_bits[ i ] ^= rhs.m_bits[ i ];
426+
}
424427
// m_zero_unused_bits();
425428
return *this;
426429
}
@@ -430,8 +433,9 @@ dynamic_bitset< Block, Allocator > &
430433
dynamic_bitset< Block, Allocator >::operator-=( const dynamic_bitset & rhs )
431434
{
432435
BOOST_ASSERT( size() == rhs.size() );
433-
for ( size_type i = 0; i < num_blocks(); ++i )
436+
for ( size_type i = 0; i < num_blocks(); ++i ) {
434437
m_bits[ i ] &= ~rhs.m_bits[ i ];
438+
}
435439
// m_zero_unused_bits();
436440
return *this;
437441
}
@@ -623,8 +627,9 @@ template< typename Block, typename Allocator >
623627
dynamic_bitset< Block, Allocator > &
624628
dynamic_bitset< Block, Allocator >::flip()
625629
{
626-
for ( size_type i = 0; i < num_blocks(); ++i )
630+
for ( size_type i = 0; i < num_blocks(); ++i ) {
627631
m_bits[ i ] = ~m_bits[ i ];
632+
}
628633
m_zero_unused_bits();
629634
return *this;
630635
}
@@ -705,10 +710,11 @@ template< typename Block, typename Allocator >
705710
bool
706711
dynamic_bitset< Block, Allocator >::any() const
707712
{
708-
for ( size_type i = 0; i < num_blocks(); ++i )
713+
for ( size_type i = 0; i < num_blocks(); ++i ) {
709714
if ( m_bits[ i ] ) {
710715
return true;
711716
}
717+
}
712718
return false;
713719
}
714720

@@ -891,10 +897,11 @@ dynamic_bitset< Block, Allocator >::
891897
is_subset_of( const dynamic_bitset< Block, Allocator > & a ) const
892898
{
893899
BOOST_ASSERT( size() == a.size() );
894-
for ( size_type i = 0; i < num_blocks(); ++i )
900+
for ( size_type i = 0; i < num_blocks(); ++i ) {
895901
if ( m_bits[ i ] & ~a.m_bits[ i ] ) {
896902
return false;
897903
}
904+
}
898905
return true;
899906
}
900907

@@ -1141,11 +1148,12 @@ operator<<( std::basic_ostream< Ch, Tr > & os, const dynamic_bitset< Block, Allo
11411148

11421149
// if needed fill at left; pad is decreased along the way
11431150
if ( adjustfield != ios_base::left ) {
1144-
for ( ; 0 < npad; --npad )
1151+
for ( ; 0 < npad; --npad ) {
11451152
if ( Tr::eq_int_type( Tr::eof(), buf->sputc( fill_char ) ) ) {
11461153
err |= ios_base::failbit;
11471154
break;
11481155
}
1156+
}
11491157
}
11501158

11511159
if ( err == ok ) {
@@ -1688,8 +1696,9 @@ dynamic_bitset< Block, Allocator >::m_append( BlockInputIterator first, BlockInp
16881696
std::size_t d = std::distance( first, last );
16891697
m_bits.reserve( num_blocks() + d );
16901698
if ( r == 0 ) {
1691-
for ( ; first != last; ++first )
1699+
for ( ; first != last; ++first ) {
16921700
m_bits.push_back( *first ); // could use vector<>::insert()
1701+
}
16931702
} else {
16941703
m_highest_block() |= ( *first << r );
16951704
do {

0 commit comments

Comments
 (0)