[libcxx-commits] [libcxx] [libcxx] Remove empty ~__no_destroy (PR #89882)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 24 01:56:21 PDT 2024
================
@@ -29,33 +29,25 @@ struct __uninitialized_tag {};
// initialization using __emplace.
template <class _Tp>
struct __no_destroy {
- _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(__uninitialized_tag) : __dummy_() {
- if (__libcpp_is_constant_evaluated()) {
- __dummy_ = char();
- }
- }
- _LIBCPP_HIDE_FROM_ABI ~__no_destroy() {
- // nothing
- }
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(__uninitialized_tag) {}
template <class... _Args>
- _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args)
- : __obj_(std::forward<_Args>(__args)...) {}
+ _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args) {
+ ::new ((void*)__obj_) _Tp(std::forward<_Args>(__args)...);
+ }
----------------
frederick-vs-ja wrote:
The `constexpr` becomes meaningless after the current changes, even after [P2747](https://wg21.link/p2747) which will be adopted for C++26 soon. Note that the always-meaningless `constexpr` on a function makes the program ill-formed, no diagnostic required before C++23.
https://github.com/llvm/llvm-project/pull/89882
More information about the libcxx-commits
mailing list