[libcxx-commits] [libcxx] [libc++][NFC] Don't use copy_n to copy a single integer in __sign_combinator (PR #181119)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 12 03:07:43 PST 2026


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

We can just assign the integer directly.


>From d924e929ffcb7a5224d8cb68802ee0d69a24a78c Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 12 Feb 2026 12:07:11 +0100
Subject: [PATCH] [libc++][NFC] Don't use copy_n to copy a single integer in
 __sign_combinator

---
 libcxx/include/__charconv/from_chars_integral.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libcxx/include/__charconv/from_chars_integral.h b/libcxx/include/__charconv/from_chars_integral.h
index 903e892cab85b..3063c0978c8fa 100644
--- a/libcxx/include/__charconv/from_chars_integral.h
+++ b/libcxx/include/__charconv/from_chars_integral.h
@@ -10,12 +10,10 @@
 #ifndef _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H
 #define _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H
 
-#include <__algorithm/copy_n.h>
 #include <__assert>
 #include <__charconv/from_chars_result.h>
 #include <__charconv/traits.h>
 #include <__config>
-#include <__memory/addressof.h>
 #include <__system_error/errc.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_integral.h>
@@ -56,8 +54,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
 
   if (__neg) {
     if (__x <= std::__complement(std::__to_unsigned_like(__tl::min()))) {
-      __x = std::__complement(__x);
-      std::copy_n(std::addressof(__x), 1, std::addressof(__value));
+      __value = std::__complement(__x);
       return __r;
     }
   } else {



More information about the libcxx-commits mailing list