[libcxx-commits] [libcxx] [libc++] Treat negative counts in copy_n & friends as no-ops (PR #207086)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 10 01:16:44 PDT 2026
================
@@ -32,15 +33,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Size, class _Func, class _Proj>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
-__for_each_n(_InputIterator __first, _Size __orig_n, _Func&& __f, _Proj& __proj) {
- typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
- _IntegralSize __n = __orig_n;
-
+__for_each_n(_InputIterator __first, _Size __n, _Func&& __f, _Proj& __proj) {
#ifndef _LIBCPP_CXX03_LANG
if constexpr (__is_segmented_iterator_v<_InputIterator>) {
using __local_iterator = typename __segmented_iterator_traits<_InputIterator>::__local_iterator;
if constexpr (__has_random_access_iterator_category<__local_iterator>::value) {
- return std::__for_each_n_segment(__first, __orig_n, [&](__local_iterator __lfirst, __local_iterator __llast) {
----------------
philnik777 wrote:
I can't remember that I did in the first place. Probably just an oversight.
https://github.com/llvm/llvm-project/pull/207086
More information about the libcxx-commits
mailing list