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 ::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 , 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