@@ -561,7 +561,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) {
561
561
capacity () >= size () + __n, " vector<bool>::__construct_at_end called with insufficient capacity" );
562
562
std::fill_n (end (), __n, __x);
563
563
this ->__size_ += __n;
564
- if (end ().__ctz_ != 0 ) // has uninitialized trailing bits in the last word
564
+ if (end ().__ctz_ != 0 ) // Ensure uninitialized leading bits in the last word are set to zero
565
565
std::fill_n (end (), __bits_per_word - end ().__ctz_ , 0 );
566
566
}
567
567
@@ -573,7 +573,7 @@ vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel _
573
573
capacity () >= size () + __n, " vector<bool>::__construct_at_end called with insufficient capacity" );
574
574
std::__copy (std::move (__first), std::move (__last), end ());
575
575
this ->__size_ += __n;
576
- if (end ().__ctz_ != 0 ) // has uninitialized trailing bits in the last word
576
+ if (end ().__ctz_ != 0 ) // Ensure uninitialized leading bits in the last word are set to zero
577
577
std::fill_n (end (), __bits_per_word - end ().__ctz_ , 0 );
578
578
}
579
579
@@ -848,9 +848,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type _
848
848
this ->__throw_length_error ();
849
849
vector __v (this ->get_allocator ());
850
850
__v.__vallocate (__n);
851
- // Ensure that the call to __construct_at_end(first, last, n) meets the precondition of n > 0
852
- if (this ->size () > 0 )
853
- __v.__construct_at_end (this ->begin (), this ->end (), this ->size ());
851
+ __v.__construct_at_end (this ->begin (), this ->end (), this ->size ());
854
852
swap (__v);
855
853
}
856
854
}
0 commit comments