[libc++] Split up __memory/base.h into meaningful headers
GitOrigin-RevId: f992cfba7173ab55d9795f71156ffde0b5eece0a
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index f315401..155d03d 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -13,11 +13,12 @@
__hash_table
__libcpp_version
__locale
+ __memory/addressof.h
__memory/allocator.h
__memory/allocator_traits.h
__memory/auto_ptr.h
- __memory/base.h
__memory/compressed_pair.h
+ __memory/construct_at.h
__memory/pointer_safety.h
__memory/pointer_traits.h
__memory/raw_storage_iterator.h
diff --git a/include/__memory/base.h b/include/__memory/addressof.h
similarity index 72%
rename from include/__memory/base.h
rename to include/__memory/addressof.h
index 70728bd..6cba912 100644
--- a/include/__memory/base.h
+++ b/include/__memory/addressof.h
@@ -7,12 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___MEMORY_BASE_H
-#define _LIBCPP___MEMORY_BASE_H
+#ifndef _LIBCPP___MEMORY_ADDRESSOF_H
+#define _LIBCPP___MEMORY_ADDRESSOF_H
#include <__config>
-#include <__debug>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -23,7 +21,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-// addressof
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
template <class _Tp>
@@ -92,36 +89,8 @@
template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
#endif
-// construct_at
-
-#if _LIBCPP_STD_VER > 17
-
-template<class _Tp, class ..._Args, class = decltype(
- ::new (_VSTD::declval<void*>()) _Tp(_VSTD::declval<_Args>()...)
-)>
-_LIBCPP_INLINE_VISIBILITY
-constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
- _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
- return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
-}
-
-#endif
-
-// destroy_at
-
-#if _LIBCPP_STD_VER > 14
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
- __loc->~_Tp();
-}
-
-#endif
-
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___MEMORY_BASE_H
+#endif // _LIBCPP___MEMORY_ADDRESSOF_H
diff --git a/include/__memory/allocator_traits.h b/include/__memory/allocator_traits.h
index be44535..bcc8356 100644
--- a/include/__memory/allocator_traits.h
+++ b/include/__memory/allocator_traits.h
@@ -11,7 +11,7 @@
#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
#include <__config>
-#include <__memory/base.h>
+#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
#include <limits>
#include <type_traits>
diff --git a/include/__memory/construct_at.h b/include/__memory/construct_at.h
new file mode 100644
index 0000000..1fef326
--- /dev/null
+++ b/include/__memory/construct_at.h
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H
+#define _LIBCPP___MEMORY_CONSTRUCT_AT_H
+
+#include <__config>
+#include <__debug>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// construct_at
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _Tp, class ..._Args, class = decltype(
+ ::new (_VSTD::declval<void*>()) _Tp(_VSTD::declval<_Args>()...)
+)>
+_LIBCPP_INLINE_VISIBILITY
+constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
+ _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
+ return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
+}
+
+#endif
+
+// destroy_at
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy_at(_Tp* __loc) {
+ _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ __loc->~_Tp();
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H
diff --git a/include/__memory/raw_storage_iterator.h b/include/__memory/raw_storage_iterator.h
index 5281875..b4842f2 100644
--- a/include/__memory/raw_storage_iterator.h
+++ b/include/__memory/raw_storage_iterator.h
@@ -11,7 +11,7 @@
#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
#include <__config>
-#include <__memory/base.h> // addressof
+#include <__memory/addressof.h>
#include <cstddef>
#include <iterator>
#include <utility>
diff --git a/include/__memory/shared_ptr.h b/include/__memory/shared_ptr.h
index 729ce16..32d9af6 100644
--- a/include/__memory/shared_ptr.h
+++ b/include/__memory/shared_ptr.h
@@ -13,10 +13,10 @@
#include <__config>
#include <__availability>
#include <__functional_base> // std::less, std::binary_function
+#include <__memory/addressof.h>
#include <__memory/allocator.h>
#include <__memory/allocator_traits.h>
#include <__memory/auto_ptr.h>
-#include <__memory/base.h> // std::addressof
#include <__memory/compressed_pair.h>
#include <__memory/pointer_traits.h>
#include <__memory/unique_ptr.h>
diff --git a/include/__memory/uninitialized_algorithms.h b/include/__memory/uninitialized_algorithms.h
index e31fd01..0873ba3 100644
--- a/include/__memory/uninitialized_algorithms.h
+++ b/include/__memory/uninitialized_algorithms.h
@@ -11,7 +11,8 @@
#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
#include <__config>
-#include <__memory/base.h> // addressof, destroy_at
+#include <__memory/addressof.h>
+#include <__memory/construct_at.h>
#include <iterator>
#include <utility>
diff --git a/include/exception b/include/exception
index 4bf4049..37751d9 100644
--- a/include/exception
+++ b/include/exception
@@ -78,7 +78,7 @@
#include <__config>
#include <__availability>
-#include <__memory/base.h>
+#include <__memory/addressof.h>
#include <cstddef>
#include <cstdlib>
#include <type_traits>
diff --git a/include/iterator b/include/iterator
index cddeb9a..4e1077f 100644
--- a/include/iterator
+++ b/include/iterator
@@ -425,7 +425,7 @@
#include <concepts>
#include <cstddef>
#include <initializer_list>
-#include <__memory/base.h>
+#include <__memory/addressof.h>
#include <__memory/pointer_traits.h>
#include <version>
#include <concepts>
diff --git a/include/memory b/include/memory
index ad97733..b3c1a86 100644
--- a/include/memory
+++ b/include/memory
@@ -678,11 +678,12 @@
#include <tuple>
#include <stdexcept>
#include <cstring>
+#include <__memory/addressof.h>
#include <__memory/allocator.h>
#include <__memory/allocator_traits.h>
#include <__memory/auto_ptr.h>
-#include <__memory/base.h>
#include <__memory/compressed_pair.h>
+#include <__memory/construct_at.h>
#include <__memory/pointer_safety.h>
#include <__memory/pointer_traits.h>
#include <__memory/raw_storage_iterator.h>