From: Amnon Hanuhov Date: Tue, 16 Mar 2021 13:37:16 +0000 (+0200) Subject: common: Added a custom deleter to make a sub-class work with std::unique_ptr X-Git-Tag: v17.1.0~2024^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0133c7ab4ead61e0cd43ea3668306e3641318788;p=ceph.git common: Added a custom deleter to make a sub-class work with std::unique_ptr Signed-off-by: Amnon Hanuhov --- diff --git a/src/common/RefCountedObj.h b/src/common/RefCountedObj.h index b23f488cad9..2de1cf14ef3 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;