[libcxx-commits] [PATCH] D55840: P0722R3: Implement library support for destroying delete

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 19 10:54:18 PDT 2019

EricWF marked 3 inline comments as done.
EricWF added a comment.

In D55840#1434761 <https://reviews.llvm.org/D55840#1434761>, @ldionne wrote:

> Please explain to me why we should have this in pre-C++20 dialects.

My users get meaningful performance improvements with this feature, but we can't upgrade everything to C++20 just yet.
For portable code, having different performance characteristics between C++17 and C++20 is a problem.

Destroying delete is a language feature first; much like aligned allocation and sized deallocation.
Given a cooperative standard library, Clang offers these features as extensions. We should cooperate.

Like aligned allocation, destroying delete is off by default and requires user opt-in.

Allowing this extension provides value to users. And it is consistent with our handling of
aligned allocation and sized deallocation.

Comment at: include/new:167
+struct destroying_delete_t {
+#ifndef _LIBCPP_CXX03_LANG
+  explicit destroying_delete_t() = default;
ldionne wrote:
> See, that's one reason why I don't like back-porting recent features to older dialects.
I don't love it either. But it's not as bad as it seams. The explicit constructor prevents `{}` from converting to `destroying_delete_t`. But in C++03 `{}` isn't a thing, so we don't have to worry about it [1].  

Clang offers the language extension in C++03. It just needs a `destroying_delete_t` definition. Users want to use destroying delete before C++20. We allow similar extensions for aligned allocation and sized deallocation.

[1] https://godbolt.org/z/EV2Efy



More information about the libcxx-commits mailing list