[libcxx-commits] [libcxx] [libc++][NFC] Use __construct_at and __destroy_at insted of using preprocessor conditionals (PR #70866)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 31 15:18:28 PDT 2023
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/70866
None
>From 71c915231666982d70306d430cea958e115c5e29 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 31 Oct 2023 23:14:10 +0100
Subject: [PATCH] [libc++][NFC] Use __construct_at and __destroy_at insted of
using preprocessor conditionals
---
libcxx/include/__memory/allocator_traits.h | 12 ++----------
libcxx/include/optional | 6 +-----
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h
index 4658098d64c9d08..12027ebc2f7aab2 100644
--- a/libcxx/include/__memory/allocator_traits.h
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -300,11 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
__enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> >
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {
-#if _LIBCPP_STD_VER >= 20
- _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
-#else
- ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
-#endif
+ std::__construct_at(__p, std::forward<_Args>(__args)...);
}
template <class _Tp, class =
@@ -319,11 +315,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
__enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
static void destroy(allocator_type&, _Tp* __p) {
-#if _LIBCPP_STD_VER >= 20
- _VSTD::destroy_at(__p);
-#else
- __p->~_Tp();
-#endif
+ std::__destroy_at(__p);
}
template <class _Ap = _Alloc, class =
diff --git a/libcxx/include/optional b/libcxx/include/optional
index ab90cc8ce7f776c..f627fe9a0d58aeb 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -416,11 +416,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_Args&&... __args)
{
_LIBCPP_ASSERT_INTERNAL(!has_value(), "__construct called for engaged __optional_storage");
-#if _LIBCPP_STD_VER >= 20
- _VSTD::construct_at(_VSTD::addressof(this->__val_), _VSTD::forward<_Args>(__args)...);
-#else
- ::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
-#endif
+ std::__construct_at(std::addressof(this->__val_), std::forward<_Args>(__args)...);
this->__engaged_ = true;
}
More information about the libcxx-commits
mailing list