[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
Thu Jul 2 00:42:50 PDT 2026
================
@@ -63,14 +63,15 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) {
using _IntegralSize = decltype(std::__convert_to_integral(__n));
_IntegralSize __converted = __n;
- if (__converted > 0) {
+ if (__converted < 0) [[__unlikely__]]
----------------
philnik777 wrote:
```suggestion
if (__converted < 0)
```
Or does this actually make a difference somewhere? Same throughout.
https://github.com/llvm/llvm-project/pull/207086
More information about the libcxx-commits
mailing list