[libcxx-commits] [libcxx] [libc++] Use __copy_n in __assign_with_size (PR #218370)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 24 03:34:14 PDT 2026


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/218370

None

>From 2a578304f8c79f53a83f0caa45e941cd26076709 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 24 Aug 2026 12:33:51 +0200
Subject: [PATCH] [libc++] Use __copy_n in __assign_with_size

---
 libcxx/include/__vector/vector.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__vector/vector.h b/libcxx/include/__vector/vector.h
index 5d2ef8fc2a583..82a5e62c4245f 100644
--- a/libcxx/include/__vector/vector.h
+++ b/libcxx/include/__vector/vector.h
@@ -986,7 +986,7 @@ vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last,
       auto __mid = std::__copy_n<_AlgPolicy>(std::move(__first), __size, this->__layout_.__begin_ptr()).__in_;
       __construct_at_end(std::move(__mid), std::move(__last), __new_size - __size);
     } else {
-      pointer __m = std::__copy(std::move(__first), __last, this->__layout_.__begin_ptr()).__out_;
+      pointer __m = std::__copy_n<_AlgPolicy>(std::move(__first), __n, this->__layout_.__begin_ptr()).__out_;
       this->__destruct_at_end(__m);
     }
   } else {



More information about the libcxx-commits mailing list