From 213f0cec5e2b78eb3048022f2731b1f7855da4a9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 14 Apr 2019 14:03:28 +0800 Subject: [PATCH] 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 --- src/msg/Message.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/msg/Message.h b/src/msg/Message.h index 75299e49261..e65cc6efc07 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 -- 2.39.5