From: Kefu Chai Date: Sun, 14 Apr 2019 06:03:28 +0000 (+0800) Subject: msg/Message: add aliases for static_pointer_cast X-Git-Tag: v15.1.0~2896^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=213f0cec5e2b78eb3048022f2731b1f7855da4a9;p=ceph.git msg/Message: add aliases for static_pointer_cast strictly speaking, they are not "alias" of boost::static_pointer_cast, but to avoid an extra conversion, instead of using boost::static_pointer_cast<>, i am using std::static_cast<> directly for creating boost::intrusive_ptr<> instance. Signed-off-by: Kefu Chai --- diff --git a/src/msg/Message.h b/src/msg/Message.h index 75299e492615..e65cc6efc071 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -573,10 +573,24 @@ template }; namespace ceph { -template -using ref_t = boost::intrusive_ptr; -template -using cref_t = boost::intrusive_ptr; +template using ref_t = boost::intrusive_ptr; +template using cref_t = boost::intrusive_ptr; +template +boost::intrusive_ptr ref_cast(const boost::intrusive_ptr& r) noexcept { + return static_cast(r.get()); +} +template +boost::intrusive_ptr ref_cast(boost::intrusive_ptr&& r) noexcept { + return {static_cast(r.detach()), false}; +} +template +boost::intrusive_ptr ref_cast(const boost::intrusive_ptr& r) noexcept { + return static_cast(r.get()); +} +template +boost::intrusive_ptr ref_cast(const boost::intrusive_ptr&& r) noexcept { + return {static_cast(r.detach()), false}; +} } #endif