[libcxx-commits] [libcxx] [libc++] Merge the implementations of ranges::copy_n and std::copy_n (PR #157444)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 9 09:10:41 PDT 2025


================
@@ -640,14 +639,7 @@ class vector {
             __enable_if_t<is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0>
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
   __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) {
-#if _LIBCPP_STD_VER >= 23
-    if constexpr (!forward_iterator<_Iterator>) { // Handles input-only sized ranges for insert_range
-      ranges::copy_n(std::move(__first), __n, __position);
-    } else
-#endif
-    {
-      std::copy_n(__first, __n, __position);
-    }
+    std::__copy_n(__first, __n, __position);
----------------
ldionne wrote:

```suggestion
    std::__copy_n(std::move(__first), __n, __position);
```

Does this fail in any test? If not, we're missing test coverage.

Edit: it seems that https://github.com/llvm/llvm-project/pull/116001 had insufficient test coverage, we didn't even check `insert_range(...)` with input-only iterators.

https://github.com/llvm/llvm-project/pull/157444


More information about the libcxx-commits mailing list