File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -246,8 +246,17 @@ class CompletionImpl final : public Completion<void(Args...), T> {
246246 std::forward<TArgs>(args)...)};
247247 }
248248
249- static void operator delete (void *p) {
250- static_cast <CompletionImpl*>(p)->destroy ();
249+ // C++20 destroying delete.
250+ // When this overload is selected by `delete ptr`, the compiler does NOT call
251+ // ~CompletionImpl(). We must do the full teardown here. We route through
252+ // destroy() so that:
253+ // - the completion’s custom lifecycle (defer/dispatch/post) is honored,
254+ // - the object’s destructor is invoked, and
255+ // - deallocation is performed using the matching allocator (RebindAlloc2).
256+ // Keep this function noexcept; destroy() is responsible for both destruction
257+ // and allocator-aware deallocation.
258+ static void operator delete (CompletionImpl* ptr, std::destroying_delete_t ) noexcept {
259+ ptr->destroy ();
251260 }
252261};
253262
You can’t perform that action at this time.
0 commit comments