1111
1212#include < __algorithm/copy.h>
1313#include < __algorithm/copy_backward.h>
14+ #include < __algorithm/copy_n.h>
1415#include < __algorithm/fill_n.h>
1516#include < __algorithm/iterator_operations.h>
1617#include < __algorithm/max.h>
@@ -701,7 +702,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v
701702 __alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc_)) {
702703 if (__v.size () > 0 ) {
703704 __vallocate (__v.size ());
704- __construct_at_end (__v.begin (), __v.end (), __v.size ());
705+ std::copy_n (__v.__begin_ , __external_cap_to_internal (__v.size ()), __begin_);
706+ __size_ = __v.size ();
705707 }
706708}
707709
@@ -710,7 +712,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v
710712 : __begin_(nullptr ), __size_(0 ), __cap_(0 ), __alloc_(__a) {
711713 if (__v.size () > 0 ) {
712714 __vallocate (__v.size ());
713- __construct_at_end (__v.begin (), __v.end (), __v.size ());
715+ std::copy_n (__v.__begin_ , __external_cap_to_internal (__v.size ()), __begin_);
716+ __size_ = __v.size ();
714717 }
715718}
716719
@@ -723,7 +726,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>
723726 __vdeallocate ();
724727 __vallocate (__v.__size_ );
725728 }
726- std::copy (__v.__begin_ , __v. __begin_ + __external_cap_to_internal (__v.__size_ ), __begin_);
729+ std::copy_n (__v.__begin_ , __external_cap_to_internal (__v.size () ), __begin_);
727730 }
728731 __size_ = __v.__size_ ;
729732 }
0 commit comments