From 0133c7ab4ead61e0cd43ea3668306e3641318788 Mon Sep 17 00:00:00 2001 From: Amnon Hanuhov Date: Tue, 16 Mar 2021 15:37:16 +0200 Subject: [PATCH] common: Added a custom deleter to make a sub-class work with std::unique_ptr Signed-off-by: Amnon Hanuhov --- src/common/RefCountedObj.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/RefCountedObj.h b/src/common/RefCountedObj.h index b23f488cad90b..2de1cf14ef3be 100644 --- a/src/common/RefCountedObj.h +++ b/src/common/RefCountedObj.h @@ -193,6 +193,14 @@ static inline void intrusive_ptr_add_ref(const RefCountedObject *p) { static inline void intrusive_ptr_release(const RefCountedObject *p) { p->put(); } +struct UniquePtrDeleter +{ + void operator()(RefCountedObject *p) const + { + // Don't expect a call to `get()` in the ctor as we manually set nref to 1 + p->put(); + } +}; } using RefCountedPtr = ceph::ref_t; -- 2.39.5