From 38f05044294b4a11ced5ba49578f7e427c492b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Dee=20=28J=C5=8Dshin=29?= Date: Wed, 28 Aug 2024 09:44:26 -0700 Subject: [PATCH] Fix __::shared_pointer deleter on bad_alloc --- ctl/shared_ptr.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ctl/shared_ptr.h b/ctl/shared_ptr.h index 7b1080097..4553c2f99 100644 --- a/ctl/shared_ptr.h +++ b/ctl/shared_ptr.h @@ -90,15 +90,14 @@ template class shared_pointer : public shared_ref { public: - static shared_pointer* make(T* const p, auto&& d) + static shared_pointer* make(T* const p, D d) { - auto p2 = unique_ptr(p); - return new shared_pointer(p2.release(), forward(d)); + auto p2 = unique_ptr(p, move(d)); + return new shared_pointer(p2.release(), move(p2.get_deleter())); } private: - shared_pointer(T* const p, auto&& d) noexcept - : p(p), d(forward(d)) + shared_pointer(T* const p, D d) noexcept : p(p), d(move(d)) { }