Skip to content

Commit 30f8c64

Browse files
authored
[libc++][NFC] Simplify std::__destroy_at a bit (#147025)
1 parent 28f0935 commit 30f8c64

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

libcxx/include/__memory/construct_at.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212

1313
#include <__assert>
1414
#include <__config>
15-
#include <__iterator/access.h>
1615
#include <__memory/addressof.h>
1716
#include <__new/placement_new_delete.h>
1817
#include <__type_traits/enable_if.h>
1918
#include <__type_traits/is_array.h>
2019
#include <__utility/declval.h>
2120
#include <__utility/forward.h>
22-
#include <__utility/move.h>
2321

2422
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2523
# pragma GCC system_header
@@ -65,11 +63,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc
6563

6664
#if _LIBCPP_STD_VER >= 20
6765
template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0>
68-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {
66+
_LIBCPP_HIDE_FROM_ABI constexpr void __destroy_at(_Tp* __loc) {
6967
_LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");
70-
auto const __end = std::end(*__loc);
71-
for (auto __it = std::begin(*__loc); __it != __end; ++__it)
72-
std::__destroy_at(__it);
68+
for (auto&& __val : *__loc)
69+
std::__destroy_at(std::addressof(__val));
7370
}
7471
#endif
7572

@@ -82,7 +79,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc)
8279

8380
# if _LIBCPP_STD_VER >= 20
8481
template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
85-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {
82+
_LIBCPP_HIDE_FROM_ABI constexpr void destroy_at(_Tp* __loc) {
8683
std::__destroy_at(__loc);
8784
}
8885
# endif

0 commit comments

Comments
 (0)