We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7ad63c0 commit 9f5bbf5Copy full SHA for 9f5bbf5
libcxx/include/__vector/vector.h
@@ -1031,9 +1031,14 @@ template <class _Tp, class _Allocator>
1031
template <class _Iterator, class _Sentinel>
1032
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1033
vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {
1034
- clear();
1035
- for (; __first != __last; ++__first)
1036
- emplace_back(*__first);
+ pointer __cur = __begin_;
+ for (; __first != __last && __cur != __end_; ++__cur, ++__first)
+ *__cur = *__first;
1037
+ if (__cur != __end_)
1038
+ __destruct_at_end(__cur);
1039
+ else
1040
+ for (; __first != __last; ++__first)
1041
+ emplace_back(*__first);
1042
}
1043
1044
template <class _Tp, class _Allocator>
0 commit comments