Skip to content

Commit a2ce24c

Browse files
Adopt @ldionne's suggestion
Co-authored-by: Louis Dionne <[email protected]>
1 parent 3f0b6d2 commit a2ce24c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

libcxx/include/__vector/vector.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,16 +1024,13 @@ vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last,
10241024
if (__new_size <= capacity()) {
10251025
if (__new_size > size()) {
10261026
#if _LIBCPP_STD_VER >= 23
1027-
if constexpr (!forward_iterator<_Iterator>) {
1028-
auto __mid = ranges::copy_n(std::move(__first), size(), this->__begin_).in;
1029-
__construct_at_end(std::move(__mid), std::move(__last), __new_size - size());
1030-
} else
1027+
auto __mid = ranges::copy_n(std::move(__first), size(), this->__begin_).in;
1028+
__construct_at_end(std::move(__mid), std::move(__last), __new_size - size());
1029+
#else
1030+
_Iterator __mid = std::next(__first, size());
1031+
std::copy(__first, __mid, this->__begin_);
1032+
__construct_at_end(__mid, __last, __new_size - size());
10311033
#endif
1032-
{
1033-
_Iterator __mid = std::next(__first, size());
1034-
std::copy(__first, __mid, this->__begin_);
1035-
__construct_at_end(__mid, __last, __new_size - size());
1036-
}
10371034
} else {
10381035
pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second;
10391036
this->__destruct_at_end(__m);

0 commit comments

Comments
 (0)