[libcxx-commits] [libcxx] 30f8c64 - [libc++][NFC] Simplify std::__destroy_at a bit (#147025)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 10 00:22:58 PDT 2025


Author: Nikolas Klauser
Date: 2025-07-10T09:22:54+02:00
New Revision: 30f8c64b1d14269fef5d11c1be69315426025dfe

URL: https://github.com/llvm/llvm-project/commit/30f8c64b1d14269fef5d11c1be69315426025dfe
DIFF: https://github.com/llvm/llvm-project/commit/30f8c64b1d14269fef5d11c1be69315426025dfe.diff

LOG: [libc++][NFC] Simplify std::__destroy_at a bit (#147025)

Added: 
    

Modified: 
    libcxx/include/__memory/construct_at.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__memory/construct_at.h b/libcxx/include/__memory/construct_at.h
index 21337e766b2d0..b64e64b5a29b0 100644
--- a/libcxx/include/__memory/construct_at.h
+++ b/libcxx/include/__memory/construct_at.h
@@ -12,14 +12,12 @@
 
 #include <__assert>
 #include <__config>
-#include <__iterator/access.h>
 #include <__memory/addressof.h>
 #include <__new/placement_new_delete.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_array.h>
 #include <__utility/declval.h>
 #include <__utility/forward.h>
-#include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -65,11 +63,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc
 
 #if _LIBCPP_STD_VER >= 20
 template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {
+_LIBCPP_HIDE_FROM_ABI constexpr void __destroy_at(_Tp* __loc) {
   _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");
-  auto const __end = std::end(*__loc);
-  for (auto __it = std::begin(*__loc); __it != __end; ++__it)
-    std::__destroy_at(__it);
+  for (auto&& __val : *__loc)
+    std::__destroy_at(std::addressof(__val));
 }
 #endif
 
@@ -82,7 +79,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc)
 
 #  if _LIBCPP_STD_VER >= 20
 template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {
+_LIBCPP_HIDE_FROM_ABI constexpr void destroy_at(_Tp* __loc) {
   std::__destroy_at(__loc);
 }
 #  endif


        


More information about the libcxx-commits mailing list