From 73eeb1324eea8b9e5725bc15b41419c1d2874be9 Mon Sep 17 00:00:00 2001 From: Shivam Kunwar Date: Wed, 4 Sep 2024 15:02:30 +0530 Subject: [PATCH] [libc++] P2590R2: Explicit lifetime management --- libcxx/include/__memory/start_lifetime_as.h | 6 +++--- libcxx/include/__memory/start_lifetime_as_array.h | 9 +++++---- libcxx/include/module.modulemap | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libcxx/include/__memory/start_lifetime_as.h b/libcxx/include/__memory/start_lifetime_as.h index f661a709c06c42..2e3292657472ca 100644 --- a/libcxx/include/__memory/start_lifetime_as.h +++ b/libcxx/include/__memory/start_lifetime_as.h @@ -32,17 +32,17 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* start_lifetime_as(void* __p) _NOEXC template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const _Tp* start_lifetime_as(const void* __p) _NOEXCEPT { - return start_lifetime_as<_Tp>(const_cast(__p)); + return std::start_lifetime_as<_Tp>(const_cast(__p)); } template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR volatile _Tp* start_lifetime_as(volatile void* __p) _NOEXCEPT { - return start_lifetime_as<_Tp>(const_cast(__p)); + return std::start_lifetime_as<_Tp>(const_cast(__p)); } template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const volatile _Tp* start_lifetime_as(const volatile void* __p) _NOEXCEPT { - return start_lifetime_as<_Tp>(const_cast(__p)); + return std::start_lifetime_as<_Tp>(const_cast(__p)); } _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__memory/start_lifetime_as_array.h b/libcxx/include/__memory/start_lifetime_as_array.h index 5b227870f7ed6c..17272c318c2ab1 100644 --- a/libcxx/include/__memory/start_lifetime_as_array.h +++ b/libcxx/include/__memory/start_lifetime_as_array.h @@ -21,25 +21,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* start_lifetime_as_array(void* __p, [[maybe_unused]] size_t __n) _NOEXCEPT { +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* +start_lifetime_as_array(void* __p, [[__maybe_unused__]] size_t __n) _NOEXCEPT { return static_cast<_Tp*>(__p); } template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const _Tp* start_lifetime_as_array(const void* __p, size_t __n) _NOEXCEPT { - return start_lifetime_as_array<_Tp>(const_cast(__p), __n); + return std::start_lifetime_as_array<_Tp>(const_cast(__p), __n); } template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR volatile _Tp* start_lifetime_as_array(volatile void* __p, size_t __n) _NOEXCEPT { - return start_lifetime_as_array<_Tp>(const_cast(__p), __n); + return std::start_lifetime_as_array<_Tp>(const_cast(__p), __n); } template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const volatile _Tp* start_lifetime_as_array(const volatile void* __p, size_t __n) _NOEXCEPT { - return start_lifetime_as_array<_Tp>(const_cast(__p), __n); + return std::start_lifetime_as_array<_Tp>(const_cast(__p), __n); } _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index f193b5d95f49f5..d340d6b33ddae4 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -1543,6 +1543,8 @@ module std_private_memory_shared_ptr [system] { header "__memory/shared_ptr.h" export std_private_memory_uninitialized_algorithms } +module std_private_memory_start_lifetime_as_array [system] { header "__memory/start_lifetime_as_array.h" } +module std_private_memory_start_lifetime_as [system] { header "__memory/start_lifetime_as.h" } module std_private_memory_swap_allocator [system] { header "__memory/swap_allocator.h" } module std_private_memory_temp_value [system] { header "__memory/temp_value.h" } module std_private_memory_temporary_buffer [system] {